From 3f9089a76741b40683e5243d1295b56bed48aac5 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 15 Aug 2015 18:42:29 +0100 Subject: [PATCH] blockchain: do not try to add a tx the pool when it was nor taken out This is an unintended difference from the old code. Though I don't think it can actually happen in practice with the current take_tx implementation. --- src/cryptonote_core/blockchain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index acbd9f9a7..37e9053c7 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2365,6 +2365,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& uint64_t t_pool = 0; uint64_t t_dblspnd = 0; uint64_t t_cc; + bool add_tx_to_pool = false; TIME_MEASURE_FINISH(t3); int tx_index = 0; @@ -2430,6 +2431,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& add_block_as_invalid(bl, id); LOG_PRINT_L1("Block with id " << id << " added as invalid because of wrong inputs in transactions"); bvc.m_verifivation_failed = true; + add_tx_to_pool = true; break; } } @@ -2445,6 +2447,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& add_block_as_invalid(bl, id); LOG_PRINT_L1("Block with id " << id << " added as invalid because of wrong inputs in transactions"); bvc.m_verifivation_failed = true; + add_tx_to_pool = true; break; } } @@ -2503,7 +2506,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash& // if we failed for any reason to verify the block, return taken // transactions to the tx_pool. - if (bvc.m_verifivation_failed || !add_success) + if ((bvc.m_verifivation_failed && add_tx_to_pool) || !add_success) { // return taken transactions to transaction pool for (auto& tx : txs)