aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/tx_pool.cpp
diff options
context:
space:
mode:
authorfluffypony <ric@spagni.net>2014-06-15 09:48:13 +0200
committerfluffypony <ric@spagni.net>2014-06-15 09:48:13 +0200
commit3bc16dc0e6bd38fbec51a054e640bacdb17a9a82 (patch)
tree314428685a9d8b6ce6471761c7775dc93cb19073 /src/cryptonote_core/tx_pool.cpp
parentadded checkpoint @ 80000 (diff)
downloadmonero-3bc16dc0e6bd38fbec51a054e640bacdb17a9a82.tar.xz
proper tx_pool handling from CryptoZoidberg / BBR
Diffstat (limited to 'src/cryptonote_core/tx_pool.cpp')
-rw-r--r--src/cryptonote_core/tx_pool.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 4c4c6aea1..ce1bc1ad2 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -83,6 +83,7 @@ namespace cryptonote
txd_p.first->second.max_used_block_id = null_hash;
txd_p.first->second.max_used_block_height = 0;
txd_p.first->second.kept_by_block = kept_by_block;
+ txd_p.first->second.receive_time = time(nullptr);
tvc.m_verifivation_impossible = true;
tvc.m_added_to_pool = true;
}else
@@ -104,6 +105,7 @@ namespace cryptonote
txd_p.first->second.max_used_block_height = max_used_block_height;
txd_p.first->second.last_failed_height = 0;
txd_p.first->second.last_failed_id = null_hash;
+ txd_p.first->second.receive_time = time(nullptr);
tvc.m_added_to_pool = true;
if(txd_p.first->second.fee > 0)
@@ -178,6 +180,30 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------------------------
+ void tx_memory_pool::on_idle()
+ {
+ m_remove_stuck_tx_interval.do_call([this](){return remove_stuck_transactions();});
+ }
+ //---------------------------------------------------------------------------------
+ //proper tx_pool handling courtesy of CryptoZoidberg and Boolberry
+ bool tx_memory_pool::remove_stuck_transactions()
+ {
+ CRITICAL_REGION_LOCAL(m_transactions_lock);
+ for(auto it = m_transactions.begin(); it!= m_transactions.end();)
+ {
+ uint64_t tx_age = time(nullptr) - it->second.receive_time;
+
+ if((tx_age > CRYPTONOTE_MEMPOOL_TX_LIVETIME && !it->second.kept_by_block) ||
+ (tx_age > CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME && it->second.kept_by_block) )
+ {
+ LOG_PRINT_L0("Tx " << it->first << " removed from tx pool due to outdated, age: " << tx_age );
+ m_transactions.erase(it++);
+ }else
+ ++it;
+ }
+ return true;
+ }
+ //---------------------------------------------------------------------------------
size_t tx_memory_pool::get_transactions_count()
{
CRITICAL_REGION_LOCAL(m_transactions_lock);