From fa24845843be70a0dfcde30bc9cd8609ee3f039c Mon Sep 17 00:00:00 2001 From: Roman Khlopkov <roman.khlopkov@demlabs.net> Date: Mon, 20 Mar 2023 11:56:46 +0300 Subject: [PATCH] [*] Mempool list format fix --- modules/common/dap_chain_datum.c | 2 +- modules/net/dap_chain_node_cli_cmd.c | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/common/dap_chain_datum.c b/modules/common/dap_chain_datum.c index ec53bf5d10..008264644b 100644 --- a/modules/common/dap_chain_datum.c +++ b/modules/common/dap_chain_datum.c @@ -228,7 +228,7 @@ bool dap_chain_datum_dump_tx(dap_chain_datum_tx_t *a_datum, l_hash_str = dap_chain_hash_fast_to_str_new(a_tx_hash); else l_hash_str = dap_enc_base58_encode_hash_to_str(a_tx_hash); - dap_string_append_printf(a_str_out, "transaction:%s hash: %s\n TS Created: %s%s%s\n Items:\n", + dap_string_append_printf(a_str_out, "transaction:%s hash %s\n TS Created: %s%s%s\n Items:\n", l_is_first ? " (emit)" : "", l_hash_str, dap_ctime_r(&l_ts_create, l_tmp_buf), a_ticker ? " Token ticker: " : "", a_ticker ? a_ticker : ""); DAP_DELETE(l_hash_str); diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 3772664240..e638d908af 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -2534,6 +2534,7 @@ void s_com_mempool_list_print_for_chain(dap_chain_net_t * a_net, dap_chain_t * a const char *l_type = NULL; DAP_DATUM_TYPE_STR(l_datum->header.type_id, l_type) const char *l_token_ticker = NULL; + bool l_is_unchained = false; if (l_datum->header.type_id == DAP_CHAIN_DATUM_TX) { // TODO rewrite it for support of multichannel & conditional transactions dap_chain_tx_in_ems_t *obj_token = (dap_chain_tx_in_ems_t*)dap_chain_datum_tx_item_get((dap_chain_datum_tx_t*)l_datum->data, NULL, TX_ITEM_TYPE_IN_EMS, NULL); if (obj_token) { @@ -2544,7 +2545,6 @@ void s_com_mempool_list_print_for_chain(dap_chain_net_t * a_net, dap_chain_t * a dap_chain_datum_tx_t *l_tx_parent = NULL; int l_item_in_size = 0; void *l_item_in = dap_chain_datum_tx_item_get((dap_chain_datum_tx_t*)l_datum->data, NULL, TX_ITEM_TYPE_IN_ALL, &l_item_in_size); - bool l_is_unchained = false; dap_hash_fast_t l_parent_hash = {0}; int l_parrent_tx_out_idx; for (int l_item_in_size_current = 0; l_item_in_size_current < l_item_in_size && !l_token_ticker;) { @@ -2587,21 +2587,15 @@ void s_com_mempool_list_print_for_chain(dap_chain_net_t * a_net, dap_chain_t * a break; } } - if (l_is_unchained) { - dap_string_append_printf(a_str_tmp, ": Transaction %s unchained. \n", l_objs[i].key); - } - if (!l_is_unchained && !l_token_ticker) { + if (!l_is_unchained && !l_token_ticker) l_token_ticker = s_ticker_list_get_main_ticker(l_tickers, a_net->pub.native_ticker); - if (!l_token_ticker) - dap_string_append_printf(a_str_tmp, ": Can't find token ticker for transaction %s. \n", l_objs[i].key); - } dap_list_free(l_tickers); } } } dap_string_append_printf(a_str_tmp, - "type_id=%s%s%s data_size=%u ts_create=%s", // \n included in timestamp - l_type, + "type_id=%s%s%s%s data_size=%u ts_create=%s", // \n included in timestamp + l_type, l_is_unchained ? "(unchainned)" : "", l_datum->header.type_id == DAP_CHAIN_DATUM_TX ? " ticker=" : "", l_token_ticker ? l_token_ticker : (l_datum->header.type_id == DAP_CHAIN_DATUM_TX ) ? "UNKNOWN" : "", -- GitLab