diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index e8b1aa3c31b465ea5b2720b75d735ca27e84e088..fb6a954d48576ff53676b61afe935b521f85a1a6 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -7266,8 +7266,10 @@ int com_tx_history(int a_argc, char ** a_argv, void **a_str_reply) bool l_brief = (dap_cli_server_cmd_check_option(a_argv, arg_index, a_argc, "-brief") != -1) ? true : false; bool l_is_tx_all = dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-all", NULL); + bool l_map1 = dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-map1", NULL); + bool l_map2 = dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-map2", NULL); - if (!l_addr_base58 && !l_wallet_name && !l_tx_hash_str && !l_is_tx_all) { + if (!l_addr_base58 && !l_wallet_name && !l_tx_hash_str && !l_is_tx_all && !l_map1 && !l_map2) { dap_json_rpc_error_add(DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_PARAM_ERR, "tx_history requires parameter '-addr' or '-w' or '-tx'"); return DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_PARAM_ERR; @@ -7406,6 +7408,10 @@ int com_tx_history(int a_argc, char ** a_argv, void **a_str_reply) json_object_array_add(*json_arr_reply, json_arr_history_all); json_object_array_add(*json_arr_reply, json_obj_summary); return DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_OK; + } else if (l_map1){ + to_map_1(true, l_chain); + } else if (l_map2){ + to_map_1(false, l_chain); } if (json_obj_out) { diff --git a/modules/net/dap_chain_node_cli_cmd_tx.c b/modules/net/dap_chain_node_cli_cmd_tx.c index 0d106f7f13958647c02be8f3d49856f08a4e83fa..491d9caf4fa58106a284bf80d97e847d258d8e8b 100644 --- a/modules/net/dap_chain_node_cli_cmd_tx.c +++ b/modules/net/dap_chain_node_cli_cmd_tx.c @@ -46,6 +46,7 @@ #include "dap_chain_mempool.h" #include "dap_math_convert.h" #include "dap_json_rpc_errors.h" +#include <sys/mman.h> #define LOG_TAG "chain_node_cli_cmd_tx" @@ -737,6 +738,26 @@ static int s_json_tx_history_pack(json_object** a_json_obj_datum, dap_chain_datu } return 0; +} +void to_map_1(bool a_t, dap_chain_t *a_chain){ + dap_chain_cell_t *l_cell, *l_iter_tmp; + HASH_ITER(hh, a_chain->cells, l_cell, l_iter_tmp) { + for (dap_list_t *it = l_cell->map_range_bounds; it; it = it->next) { + if (a_t){ + int error = madvise(it->data, it->next->data - it->data, MADV_SEQUENTIAL); + log_it(L_MSG, "MADV_SEQ %d", error); + //int error2 = madvise(it->data, it->next->data - it->data, MADV_POPULATE_READ); + //log_it(L_MSG, "MADV_POPL_READ %d", error2); + + } else { + int error3 = madvise(it->data, it->next->data - it->data, MADV_WILLNEED); + log_it(L_MSG, "MADV_WILLNEED %d", error3); + } + + it = it->next; + } + } + } json_object *dap_db_history_tx_all(dap_chain_t *a_chain, dap_chain_net_t *a_net, @@ -760,18 +781,7 @@ json_object *dap_db_history_tx_all(dap_chain_t *a_chain, dap_chain_net_t *a_net, bool look_for_unknown_service = (a_srv && strcmp(a_srv,"unknown") == 0); // load transactions dap_chain_datum_iter_t *l_datum_iter = a_chain->callback_datum_iter_create(a_chain); - dap_chain_cell_t *l_cell, *l_iter_tmp; - HASH_ITER(hh, a_chain->cells, l_cell, l_iter_tmp) { - for (dap_list_t *it = l_cell->map_range_bounds; it; it = it->next) { - int error = madvise(it->data, it->next->data - it->data, MADV_SEQUENTIAL); - log_it(L_MSG, "MADV_SEQ %d", error); - int error2 = madvise(it->data, it->next->data - it->data, MADV_POPULATE_READ); - log_it(L_MSG, "MADV_POPL_READ %d", error2); - int error3 = madvise(it->data, it->next->data - it->data, MADV_WILLNEED); - log_it(L_MSG, "MADV_WILLNEED %d", error3); - it = it->next; - } - } + dap_chain_datum_callback_iters iter_begin; dap_chain_datum_callback_iters iter_direc; iter_begin = a_head ? a_chain->callback_datum_iter_get_first diff --git a/modules/net/include/dap_chain_node_cli_cmd_tx.h b/modules/net/include/dap_chain_node_cli_cmd_tx.h index 375f1f34f2474baf60f60e02f6916f11028c1834..00f059a61bd75db5b2a85cb266b05b26fcaafa0a 100644 --- a/modules/net/include/dap_chain_node_cli_cmd_tx.h +++ b/modules/net/include/dap_chain_node_cli_cmd_tx.h @@ -112,4 +112,5 @@ typedef enum s_com_token_err{ * */ int cmd_decree(int a_argc, char **a_argv, void **a_str_reply); +void to_map_1(bool a_t, dap_chain_t *a_chain);