diff --git a/modules/net/dap_chain_ledger.c b/modules/net/dap_chain_ledger.c index c912bc0e619520854229029b53167af4d146cc4a..b59f1894a4f24330f60e12903278a50c6bd339fd 100644 --- a/modules/net/dap_chain_ledger.c +++ b/modules/net/dap_chain_ledger.c @@ -3378,18 +3378,21 @@ static int s_tx_cache_check(dap_ledger_t *a_ledger, bool a_check_for_removing) { dap_return_val_if_fail(a_ledger && a_tx && a_tx_hash, DAP_LEDGER_CHECK_INVALID_ARGS); - if (!dap_chain_net_get_load_mode(a_ledger->net) && !a_from_threshold && !a_check_for_removing) { + if (!a_from_threshold) { dap_ledger_tx_item_t *l_ledger_item = NULL; pthread_rwlock_rdlock(&PVT(a_ledger)->ledger_rwlock); HASH_FIND(hh, PVT(a_ledger)->ledger_items, a_tx_hash, sizeof(dap_chain_hash_fast_t), l_ledger_item); pthread_rwlock_unlock(&PVT(a_ledger)->ledger_rwlock); - if (l_ledger_item) { // transaction already present in the cache list + if (l_ledger_item && !a_check_for_removing ) { // transaction already present in the cache list if (s_debug_more) { log_it(L_WARNING, "Transaction %s already present in the cache", dap_chain_hash_fast_to_str_static(a_tx_hash)); if (a_tag) *a_tag = l_ledger_item->cache_data.tag; if (a_action) *a_action = l_ledger_item->cache_data.action; } return DAP_LEDGER_CHECK_ALREADY_CACHED; + } else if (!l_ledger_item && a_check_for_removing) { // transaction already present in the cache list + debug_if(s_debug_more, L_WARNING, "Transaction %s not present in the cache. Can not delete it. Skip.", dap_chain_hash_fast_to_str_static(a_tx_hash)); + return DAP_LEDGER_TX_CHECK_FOR_REMOVING_CANT_FIND_TX; } } /* diff --git a/modules/net/include/dap_chain_ledger.h b/modules/net/include/dap_chain_ledger.h index 7aafc5faef5b37b81b9f379a766583e1dec3b50c..6c5c487316371532bc920e335429b1b1a552f555 100644 --- a/modules/net/include/dap_chain_ledger.h +++ b/modules/net/include/dap_chain_ledger.h @@ -89,6 +89,7 @@ typedef enum dap_ledger_check_error { DAP_LEDGER_TX_CHECK_UNEXPECTED_TOKENIZED_OUT, DAP_LEDGER_TX_CHECK_NOT_ENOUGH_FEE, DAP_LEDGER_TX_CHECK_NOT_ENOUGH_TAX, + DAP_LEDGER_TX_CHECK_FOR_REMOVING_CANT_FIND_TX, /* Emisssion check return codes */ DAP_LEDGER_EMISSION_CHECK_VALUE_EXCEEDS_CURRENT_SUPPLY, DAP_LEDGER_EMISSION_CHECK_LEGACY_FORBIDDEN, @@ -145,6 +146,7 @@ DAP_STATIC_INLINE const char *dap_ledger_check_error_str(dap_ledger_check_error_ case DAP_LEDGER_TX_CHECK_UNEXPECTED_TOKENIZED_OUT: return "Tokenized out is forbidden for single-channel trandactions"; case DAP_LEDGER_TX_CHECK_NOT_ENOUGH_FEE: return "Not enough network fee for transaction processing"; case DAP_LEDGER_TX_CHECK_NOT_ENOUGH_TAX: return "Not enough sovereign tax provided with current transaction"; + case DAP_LEDGER_TX_CHECK_FOR_REMOVING_CANT_FIND_TX: return "Can't find tx in ledger for removing."; /* Emisssion check return codes */ case DAP_LEDGER_EMISSION_CHECK_VALUE_EXCEEDS_CURRENT_SUPPLY: return "Value of emission execeeds current token supply"; case DAP_LEDGER_EMISSION_CHECK_LEGACY_FORBIDDEN: return "Legacy type of emissions are present for old chains comliance only"; diff --git a/modules/type/blocks/dap_chain_cs_blocks.c b/modules/type/blocks/dap_chain_cs_blocks.c index 17180d9a64676e2a41ebf7f06e577663ec8951b0..0b76090d0f15515fc5362c0e5996f22da9e20602 100644 --- a/modules/type/blocks/dap_chain_cs_blocks.c +++ b/modules/type/blocks/dap_chain_cs_blocks.c @@ -1749,8 +1749,7 @@ static dap_chain_atom_verify_res_t s_callback_atom_add(dap_chain_t * a_chain, da } debug_if(s_debug_more, L_DEBUG, "... new block %s", l_block_cache->block_hash_str); dap_chain_block_cache_t *l_prev_bcache = NULL, *l_tmp = NULL; - pthread_rwlock_wrlock(& PVT(l_blocks)->rwlock); - log_it(L_INFO, "New fork. Previous block hash %s, current block hash %s", dap_chain_hash_fast_to_str_static(&l_block_prev_hash), + pthread_rwlock_wrlock(& PVT(l_blocks)->rwlock); log_it(L_INFO, "New fork. Previous block hash %s, current block hash %s", dap_chain_hash_fast_to_str_static(&l_block_prev_hash), l_block_cache->block_hash_str); HASH_FIND(hh, PVT(l_blocks)->blocks, &l_block_prev_hash, sizeof(dap_hash_fast_t), l_prev_bcache); if (l_prev_bcache){