diff --git a/dap_chain_net.c b/dap_chain_net.c index fdf4ca9b822a94d897c5671e8e48c329087c499c..cd2df9fb4ea8b8cf39b11d9c13ed1e8af909b33f 100644 --- a/dap_chain_net.c +++ b/dap_chain_net.c @@ -242,22 +242,6 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name , DAP_DELETE(ret); return NULL; } - else if(strcmp(a_node_role, "master") == 0) { - PVT(ret)->node_role.enums = MASTER; - log_it(L_NOTICE, "Node role \"root\" selected"); - } - else if(strcmp(a_node_role, "archive") == 0) { - PVT(ret)->node_role.enums = ARCHIVE; - log_it(L_NOTICE, "Node role \"root\" selected"); - } - else if(strcmp(a_node_role, "full") == 0) { - PVT(ret)->node_role.enums = FULL; - log_it(L_NOTICE, "Node role \"root\" selected"); - } - else if(strcmp(a_node_role, "ligth") == 0) { - PVT(ret)->node_role.enums = LIGHT; - log_it(L_NOTICE, "Node role \"root\" selected"); - } } else { log_it (L_ERROR, "Wrong id format (\"%s\"). Must be like \"0x0123456789ABCDE\"" , a_id ); DAP_DELETE(ret); diff --git a/dap_chain_node_cli.c b/dap_chain_node_cli.c index 9b84aefe79b4da04acf410e01e4d66be91f6ca82..be7a283764cdb94d970cf9f6502b5e0078807c18 100644 --- a/dap_chain_node_cli.c +++ b/dap_chain_node_cli.c @@ -515,6 +515,10 @@ int dap_chain_node_cli_init(dap_config_t * g_config) dap_chain_node_cli_cmd_item_create ("tx_verify", com_tx_verify, "Verifing transaction", "tx_verify -wallet <wallet name> [-path <wallet path>]\n" ); + // Log + dap_chain_node_cli_cmd_item_create ("print_log", com_print_log, "Print log info", + "print_log [ts_after <timestamp >] [limit <line numbers>]\n" ); + // init client for handshake diff --git a/dap_chain_node_cli_cmd.c b/dap_chain_node_cli_cmd.c index cfaad25febe846c0d2965b8f39fc247509b62459..71e410f37c70783f6945edc58234562af1b7885d 100644 --- a/dap_chain_node_cli_cmd.c +++ b/dap_chain_node_cli_cmd.c @@ -1904,7 +1904,7 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) const char * l_certs_str = NULL; dap_chain_cert_t ** l_certs = NULL; - size_t l_certs_count = 0; + size_t l_certs_size = 0; const char * l_chain_str = NULL; dap_chain_t * l_chain; @@ -1950,7 +1950,7 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) // Load certs dap_chain_cert_parse_str_list(l_certs_str,&l_certs,&l_certs_size); - if(!l_certs_count) { + if(!l_certs_size) { dap_chain_node_cli_set_reply_text(str_reply, "token_emit command requres at least one valid certificate to sign the basic transaction of emission"); return -5; @@ -2035,7 +2035,7 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_out); // Sign all that we have with certs - for(size_t i = 0; i < l_certs_count; i++) { + for(size_t i = 0; i < l_certs_size; i++) { if(dap_chain_datum_tx_add_sign_item(&l_tx, l_certs[i]->enc_key) < 0) { dap_chain_node_cli_set_reply_text(str_reply, "No private key for certificate=%s", l_certs[i]->name); @@ -2228,3 +2228,37 @@ int com_tx_verify(int argc, const char ** argv, char **str_reply) dap_chain_node_cli_set_reply_text(str_reply, "command not defined, enter \"help <cmd name>\""); return -1; } + +/** + * print_log command + * + * Print log info + * print_log [ts_after <timestamp >] [limit <line numbers>] + */ +int com_print_log(int argc, const char ** argv, char **str_reply) +{ + int arg_index = 1; + const char * l_str_ts_after = NULL; + const char * l_str_limit = NULL; + int64_t l_ts_after = 0; + int32_t l_limit = 0; + dap_chain_node_cli_find_option_val(argv, arg_index, argc, "ts_after", &l_str_ts_after); + dap_chain_node_cli_find_option_val(argv, arg_index, argc, "limit", &l_str_limit); + + l_ts_after = (l_str_ts_after) ? strtoll(l_str_ts_after, 0, 10) : -1; + l_limit = (l_str_limit) ? strtol(l_str_limit, 0, 10) : -1; + + if(l_ts_after<0 || !l_str_ts_after) { + dap_chain_node_cli_set_reply_text(str_reply, "requires valid parameter 'l_ts_after'"); + return -1; + } + if(!l_limit) { + dap_chain_node_cli_set_reply_text(str_reply, "requires valid parameter 'limit'"); + return -1; + } + + char *l_str_ret = NULL; + dap_chain_node_cli_set_reply_text(str_reply, l_str_ret); + return -1; +} + diff --git a/dap_chain_node_cli_cmd.h b/dap_chain_node_cli_cmd.h index 3428ccb42aa6d3c2fb740fa744a795d72687e29c..47a195186f578d0fa889ad19660061c8783a983f 100644 --- a/dap_chain_node_cli_cmd.h +++ b/dap_chain_node_cli_cmd.h @@ -111,5 +111,8 @@ int com_tx_cond_create(int argc, const char ** argv, char **str_reply); */ int com_tx_verify(int argc, const char ** argv, char **str_reply); +// Print log info +int com_print_log(int argc, const char ** argv, char **str_reply); + int com_mempool_list(int argc, const char ** argv, char ** a_str_reply); int com_mempool_proc(int argc, const char ** argv, char ** a_str_reply);