From 3d2ce52b8e72ded224d5f51a22b3db25de1bb735 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 2 Jun 2025 23:50:31 +0400 Subject: [PATCH] small performance tweak of fill_block_template and more logs related to pool txs blacklisting --- src/currency_core/tx_pool.cpp | 24 ++++++++++++++++++++---- src/currency_core/tx_pool.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/currency_core/tx_pool.cpp b/src/currency_core/tx_pool.cpp index 4c98db89..d0649b39 100644 --- a/src/currency_core/tx_pool.cpp +++ b/src/currency_core/tx_pool.cpp @@ -723,15 +723,26 @@ namespace currency return true; } //--------------------------------------------------------------------------------- + std::string tx_memory_pool::get_blacklisted_txs_string() const + { + std::stringstream ss; + m_db_black_tx_list.enumerate_items([&](uint64_t i, const crypto::hash& td_id, const bool& /*dummy */ ) + { + ss << td_id << ENDL; + return true; + }); + return ss.str(); + } + //--------------------------------------------------------------------------------- bool tx_memory_pool::add_transaction_to_black_list(const transaction& tx) { // atm: // 1) the only side effect of a tx being blacklisted is the one is just ignored by fill_block_template(), but it still can be added to blockchain/pool // 2) it's permanent - LOG_PRINT_YELLOW("TX ADDED TO POOL'S BLACKLIST: " << get_transaction_hash(tx), LOG_LEVEL_0); m_db.begin_transaction(); m_db_black_tx_list.set(get_transaction_hash(tx), true); m_db.commit_transaction(); + LOG_PRINT_YELLOW("TX ADDED TO POOL'S BLACKLIST: " << get_transaction_hash(tx) << ", full black list: " << ENDL << get_blacklisted_txs_string(), LOG_LEVEL_0); return true; } //--------------------------------------------------------------------------------- @@ -908,8 +919,12 @@ namespace currency { //not the best implementation at this time, sorry :( - if (is_tx_blacklisted(get_transaction_hash(txd.tx))) + if (is_tx_blacklisted(id)) + { + LOG_PRINT_L2("[is_transaction_ready_to_go]Tx " << id << " skipped as it blacklisted"); return false; + } + //check is ring_signature already checked ? if(txd.max_used_block_id == null_hash) @@ -1193,13 +1208,14 @@ namespace currency if (i < best_position) { bl.tx_hashes.push_back(tx.first); + LOG_PRINT_L2("[fill_block_template]: Added tx to block: " << tx.first); } - else if (have_attachment_service_in_container(tx.second->tx.attachment, BC_OFFERS_SERVICE_ID, BC_OFFERS_SERVICE_INSTRUCTION_DEL)) + /*else if (have_attachment_service_in_container(tx.second->tx.attachment, BC_OFFERS_SERVICE_ID, BC_OFFERS_SERVICE_INSTRUCTION_DEL)) { // BC_OFFERS_SERVICE_INSTRUCTION_DEL transactions has zero fee, so include them here regardless of reward effectiveness bl.tx_hashes.push_back(tx.first); total_size += tx.second->blob_size; - } + }*/ } } // add explicit transactions diff --git a/src/currency_core/tx_pool.h b/src/currency_core/tx_pool.h index c97a498a..e573d2b5 100644 --- a/src/currency_core/tx_pool.h +++ b/src/currency_core/tx_pool.h @@ -155,6 +155,7 @@ namespace currency bool insert_alias_info(const transaction& tx); bool remove_alias_info(const transaction& tx); bool check_tx_fee(const transaction &tx, uint64_t amount_fee); + std::string get_blacklisted_txs_string() const; bool is_valid_contract_finalization_tx(const transaction &tx)const; void store_db_solo_options_values();