1
0
Fork 0
forked from lthn/blockchain

small performance tweak of fill_block_template and more logs related to pool txs blacklisting

This commit is contained in:
cryptozoidberg 2025-06-02 23:50:31 +04:00
parent d85b94df92
commit 3d2ce52b8e
No known key found for this signature in database
GPG key ID: 2E10CC61CAC8F36D
2 changed files with 21 additions and 4 deletions

View file

@ -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

View file

@ -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();