diff --git a/modules/node-cli/dap_chain_node_cli_cmd_tx.c b/modules/node-cli/dap_chain_node_cli_cmd_tx.c index c10e932cf7e8eabe79e366869dd8e69b7df3e8c1..8884d4a18b620d5620cac6e7dcb98e1053e90776 100644 --- a/modules/node-cli/dap_chain_node_cli_cmd_tx.c +++ b/modules/node-cli/dap_chain_node_cli_cmd_tx.c @@ -2057,7 +2057,7 @@ int com_tx_history(int a_argc, char ** a_argv, void **a_str_reply) dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-limit", &l_limit_str); dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-offset", &l_offset_str); bool l_head = dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-head", &l_head_str) ? true : false; - size_t l_limit = l_limit_str ? strtoul(l_limit_str, NULL, 10) : 0; + size_t l_limit = l_limit_str ? strtoul(l_limit_str, NULL, 10) : 1000; size_t l_offset = l_offset_str ? strtoul(l_offset_str, NULL, 10) : 0; //default is ALL/ANY diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c index 2cfa21a90a5bd639c82a90ee2b3d759b369f1994..d693f63c71c42a06d7aa22da0df63674d6ec1082 100644 --- a/modules/service/xchange/dap_chain_net_srv_xchange.c +++ b/modules/service/xchange/dap_chain_net_srv_xchange.c @@ -225,7 +225,7 @@ int dap_chain_net_srv_xchange_init() "\tShows transaction history for the selected order\n" "srv_xchange order status -net <net_name> -order <order_hash>\n" "\tShows current amount of unselled coins from the selected order and percentage of its completion\n" - "srv_xchange orders -net <net_name> [-status {opened|closed|all}] [-token_from <token_ticker>] [-token_to <token_ticker>] [-addr <wallet_addr>] [-limit <limit>] [-offset <offset>]\n" + "srv_xchange orders -net <net_name> [-status {opened|closed|all}] [-token_from <token_ticker>] [-token_to <token_ticker>] [-addr <wallet_addr>] [-limit <limit>] [-offset <offset>] [-head]\n" "\tGet the exchange orders list within specified net name\n" "srv_xchange purchase -order <order hash> -net <net_name> -w <wallet_name> -value <value> -fee <value>\n" @@ -2365,6 +2365,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) const char * l_token_from_str = NULL; const char * l_token_to_str = NULL; + const char * l_head_str = NULL; dap_cli_server_cmd_find_option_val(a_argv, l_arg_index, a_argc, "-token_from", &l_token_from_str); if(l_token_from_str){ dap_chain_datum_token_t * l_token_from_datum = dap_ledger_token_ticker_check( l_net->pub.ledger, l_token_from_str); @@ -2385,6 +2386,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) } } + bool l_head = dap_cli_server_cmd_find_option_val(a_argv, l_arg_index, a_argc, "-head", &l_head_str) ? true : false; dap_chain_addr_t *l_addr = NULL; const char *l_addr_str = NULL; dap_cli_server_cmd_find_option_val(a_argv, l_arg_index, a_argc, "-addr", &l_addr_str); @@ -2407,7 +2409,8 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) json_object_object_add(json_obj_order, "PAGINA", json_arr_orders_limit); size_t i_tmp = 0; // Print all txs - for (dap_list_t *it = l_list; it; it = it->next) { + for (dap_list_t *it = l_head ? dap_list_last(l_list) : dap_list_first(l_list); + it; it = l_head ? it->prev : it->next) { dap_chain_datum_tx_t *l_tx = NULL; char l_buy_token[DAP_CHAIN_TICKER_SIZE_MAX] = {0}; char l_sell_token[DAP_CHAIN_TICKER_SIZE_MAX] = {0}; @@ -2514,10 +2517,14 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) continue; } - if (i_tmp < l_arr_start || i_tmp >= l_arr_end) { + if (i_tmp < l_arr_start) { i_tmp++; continue; } + + if (i_tmp >= l_arr_end) { + break; + } i_tmp++; char l_tmp_buf[DAP_TIME_STR_SIZE]; @@ -2547,6 +2554,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) json_object_array_add(*json_arr_reply, json_obj_order); DAP_DELETE(l_owner_addr); l_printed_orders_count++; + if (l_head && (it->prev->next == NULL)) break; } json_object_object_add(json_obj_order, "ORDERS", json_arr_orders_out); json_object_array_add(*json_arr_reply, json_obj_order);