From 13d9fc5abb43f996b771466a1b6b39fe9c34e525 Mon Sep 17 00:00:00 2001 From: Olzhas <oljas.jarasbaev@demlabs.net> Date: Mon, 29 Jul 2024 11:21:02 +0700 Subject: [PATCH] [*] logs fix --- dap-sdk | 2 +- modules/chain/dap_chain.c | 2 +- modules/net/dap_chain_net.c | 1 + modules/net/dap_chain_net_anchor.c | 8 +++++++- modules/net/dap_chain_net_decree.c | 7 +++++-- modules/net/include/dap_chain_net_anchor.h | 2 +- .../service/stake/dap_chain_net_srv_stake_pos_delegate.c | 6 ++++-- modules/type/blocks/dap_chain_block.c | 3 ++- modules/type/blocks/dap_chain_cs_blocks.c | 1 + 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dap-sdk b/dap-sdk index 7e3bc51a40..2a84146f1d 160000 --- a/dap-sdk +++ b/dap-sdk @@ -1 +1 @@ -Subproject commit 7e3bc51a4004f0a3163578430c784caf40f61d00 +Subproject commit 2a84146f1d73c7690497762be1e922b4ecbe20ef diff --git a/modules/chain/dap_chain.c b/modules/chain/dap_chain.c index 712acc0c47..3026156c78 100644 --- a/modules/chain/dap_chain.c +++ b/modules/chain/dap_chain.c @@ -591,7 +591,7 @@ bool download_notify_callback(dap_chain_t* a_chain) { json_object_object_add(l_chain_info, "chain_id", json_object_new_uint64(a_chain->id.uint64)); json_object_object_add(l_chain_info, "load_progress", json_object_new_int(a_chain->load_progress)); dap_notify_server_send_mt(json_object_get_string(l_chain_info)); - log_it(L_DEBUG, "Load progress: net_name: %s; chain_id: %" DAP_UINT64_FORMAT_U "; download:%d%%", a_chain->net_name, a_chain->id.uint64, a_chain->load_progress); + log_it(L_DEBUG, "Loading net \"%s\", chain %" DAP_UINT64_FORMAT_U " [%d%%]", a_chain->net_name, a_chain->id.uint64, a_chain->load_progress); json_object_put(l_chain_info); return true; } diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 9127fa64b6..476e0cb8ea 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -256,6 +256,7 @@ int dap_chain_net_init() { dap_ledger_init(); dap_chain_ch_init(); + dap_chain_net_anchor_init(); dap_stream_ch_chain_net_init(); dap_chain_node_client_init(); dap_chain_net_srv_voting_init(); diff --git a/modules/net/dap_chain_net_anchor.c b/modules/net/dap_chain_net_anchor.c index 60afafe6f8..b5f7d7fb1a 100644 --- a/modules/net/dap_chain_net_anchor.c +++ b/modules/net/dap_chain_net_anchor.c @@ -50,6 +50,12 @@ typedef struct anchor_table{ static bool s_verify_pubkeys(dap_sign_t *a_sign, dap_sign_t **a_decree_signs, size_t a_num_of_decree_sign); static inline dap_sign_t *s_concate_all_signs_in_array(dap_sign_t *a_in_signs, size_t a_signs_size, size_t *a_sings_count, size_t *a_signs_arr_size); +static bool s_debug_more = false; + +int dap_chain_net_anchor_init() { + s_debug_more = dap_config_get_item_bool_default(g_config,"chain_net","debug_more", s_debug_more); +} + static int s_anchor_verify(dap_chain_net_t *a_net, dap_chain_datum_anchor_t *a_anchor, size_t a_data_size, bool a_load_mode) { if (a_data_size < sizeof(dap_chain_datum_anchor_t)) @@ -161,7 +167,7 @@ int dap_chain_net_anchor_load(dap_chain_datum_anchor_t * a_anchor, dap_chain_t * } if ((ret_val = dap_chain_net_decree_apply(&l_hash, NULL, a_chain)) != 0){ - log_it(L_WARNING, "Decree applying failed"); + debug_if(s_debug_more, L_WARNING, "Decree applying failed"); return ret_val; } diff --git a/modules/net/dap_chain_net_decree.c b/modules/net/dap_chain_net_decree.c index 7dc38736df..4cc2826b82 100644 --- a/modules/net/dap_chain_net_decree.c +++ b/modules/net/dap_chain_net_decree.c @@ -55,6 +55,7 @@ static bool s_verify_pkey (dap_sign_t *a_sign, dap_chain_net_t *a_net); static int s_common_decree_handler(dap_chain_datum_decree_t *a_decree, dap_chain_net_t *a_net, bool a_apply, bool a_load_mode); static int s_service_decree_handler(dap_chain_datum_decree_t *a_decree, dap_chain_net_t *a_net, bool a_apply); +static bool s_debug_more = false; // Public functions int dap_chain_net_decree_init(dap_chain_net_t *a_net) @@ -66,6 +67,8 @@ int dap_chain_net_decree_init(dap_chain_net_t *a_net) return -106; } + s_debug_more = dap_config_get_item_bool_default(g_config,"chain_net","debug_more", s_debug_more); + dap_list_t *l_net_keys = NULL; uint16_t l_count_verify = 0; for (dap_chain_t *l_chain = a_net->pub.chains; l_chain; l_chain = l_chain->next) { @@ -293,7 +296,7 @@ int dap_chain_net_decree_apply(dap_hash_fast_t *a_decree_hash, dap_chain_datum_d l_new_decree->is_applied = true; l_new_decree->wait_for_apply = false; } else - log_it(L_ERROR,"Decree applying failed!"); + debug_if(s_debug_more, L_ERROR,"Decree applying failed!"); return ret_val; } @@ -435,7 +438,7 @@ static int s_common_decree_handler(dap_chain_datum_decree_t *a_decree, dap_chain break; } if (dap_chain_net_srv_stake_verify_key_and_node(&l_addr, &l_node_addr)) { - log_it(L_WARNING, "Key and node verification error"); + debug_if(s_debug_more, L_WARNING, "Key and node verification error"); return -109; } if (!a_apply) diff --git a/modules/net/include/dap_chain_net_anchor.h b/modules/net/include/dap_chain_net_anchor.h index 7275e2c2b3..cb19ca0811 100644 --- a/modules/net/include/dap_chain_net_anchor.h +++ b/modules/net/include/dap_chain_net_anchor.h @@ -24,7 +24,7 @@ #include "dap_chain_datum_anchor.h" #include "dap_chain_net.h" -int dap_chain_net_anchor_init(dap_chain_net_t *a_net); +int dap_chain_net_anchor_init(); int dap_chain_net_anchor_verify(dap_chain_net_t *a_net, dap_chain_datum_anchor_t * a_anchor, size_t a_data_size); int dap_chain_net_anchor_load(dap_chain_datum_anchor_t * a_anchor, dap_chain_t *a_chain, dap_hash_fast_t *a_anchor_hash); diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c index f432b73eee..91452779e5 100644 --- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c +++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c @@ -59,6 +59,8 @@ static void s_uncache_data(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, d static dap_list_t *s_srv_stake_list = NULL; +static bool s_debug_more = false; + static bool s_tag_check_key_delegation(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_datum_tx_item_groups_t *a_items_grp, dap_chain_tx_tag_action_type_t *a_action) { // keydelegation open: have STAK_POS_DELEGATE out @@ -553,7 +555,7 @@ int dap_chain_net_srv_stake_verify_key_and_node(dap_chain_addr_t *a_signing_addr char l_key_hash_str[DAP_CHAIN_HASH_FAST_STR_SIZE]; dap_chain_hash_fast_to_str(&a_signing_addr->data.hash_fast, l_key_hash_str, DAP_CHAIN_HASH_FAST_STR_SIZE); - log_it(L_WARNING, "Key %s already active for node "NODE_ADDR_FP_STR, + debug_if(s_debug_more, L_WARNING, "Key %s already active for node "NODE_ADDR_FP_STR, l_key_hash_str, NODE_ADDR_FP_ARGS_S(l_stake->node_addr)); return -101; } @@ -563,7 +565,7 @@ int dap_chain_net_srv_stake_verify_key_and_node(dap_chain_addr_t *a_signing_addr char l_key_hash_str[DAP_CHAIN_HASH_FAST_STR_SIZE]; dap_chain_hash_fast_to_str(&l_stake->signing_addr.data.hash_fast, l_key_hash_str, DAP_CHAIN_HASH_FAST_STR_SIZE); - log_it(L_WARNING, "Node "NODE_ADDR_FP_STR" already have active key %s", + debug_if(s_debug_more, L_WARNING, "Node "NODE_ADDR_FP_STR" already have active key %s", NODE_ADDR_FP_ARGS(a_node_addr), l_key_hash_str); return -102; } diff --git a/modules/type/blocks/dap_chain_block.c b/modules/type/blocks/dap_chain_block.c index dc602a255c..2f64b416a6 100644 --- a/modules/type/blocks/dap_chain_block.c +++ b/modules/type/blocks/dap_chain_block.c @@ -30,6 +30,7 @@ #define LOG_TAG "dap_chain_block" bool s_seed_mode = false; +bool s_dap_block_debug_more = false; /** * @brief dap_chain_block_init @@ -38,7 +39,7 @@ bool s_seed_mode = false; int dap_chain_block_init() { s_seed_mode = dap_config_get_item_bool_default(g_config,"general","seed_mode",false); - + s_dap_block_debug_more = dap_config_get_item_bool_default(g_config, "blocks", "debug_more", false); return 0; } diff --git a/modules/type/blocks/dap_chain_cs_blocks.c b/modules/type/blocks/dap_chain_cs_blocks.c index b35ce03bed..a1724ab32d 100644 --- a/modules/type/blocks/dap_chain_cs_blocks.c +++ b/modules/type/blocks/dap_chain_cs_blocks.c @@ -167,6 +167,7 @@ static bool s_debug_more = false; */ int dap_chain_cs_blocks_init() { + dap_chain_block_init(); dap_chain_cs_type_add("blocks", s_chain_cs_blocks_new); s_seed_mode = dap_config_get_item_bool_default(g_config,"general","seed_mode",false); s_debug_more = dap_config_get_item_bool_default(g_config, "blocks", "debug_more", false); -- GitLab