From 0048680467e15037023ceae44bc2dc8309f82f39 Mon Sep 17 00:00:00 2001 From: marcofleon Date: Tue, 28 May 2024 09:45:19 -0700 Subject: [PATCH 1/2] increase txorphan harness stability initialize variable --- src/txorphanage.cpp | 1 - src/txorphanage.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index 8e76c07b07230..cfafadcb98771 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -119,7 +119,6 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng) LOCK(m_mutex); unsigned int nEvicted = 0; - static NodeSeconds nNextSweep; auto nNow{Now()}; if (nNextSweep <= nNow) { // Sweep out expired orphan pool entries: diff --git a/src/txorphanage.h b/src/txorphanage.h index 47becb447df4c..2da85828690e3 100644 --- a/src/txorphanage.h +++ b/src/txorphanage.h @@ -105,6 +105,9 @@ class TxOrphanage { /** Erase an orphan by wtxid */ int EraseTxNoLock(const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex); + + /** Timestamp for the next scheduled sweep of expired orphans */ + NodeSeconds nNextSweep GUARDED_BY(m_mutex){0s}; }; #endif // BITCOIN_TXORPHANAGE_H From 8defc182a31d828ad0f53ebf7e3be9e9cfc42d09 Mon Sep 17 00:00:00 2001 From: marcofleon Date: Wed, 29 May 2024 08:53:50 -0700 Subject: [PATCH 2/2] scripted-diff: Replace nNextSweep with m_next_sweep -BEGIN VERIFY SCRIPT- sed -i 's/nNextSweep/m_next_sweep/g' $(git grep -l 'nNextSweep') -END VERIFY SCRIPT- fixing to match style --- src/txorphanage.cpp | 4 ++-- src/txorphanage.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index cfafadcb98771..3eaf53939dfdb 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -120,7 +120,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng) unsigned int nEvicted = 0; auto nNow{Now()}; - if (nNextSweep <= nNow) { + if (m_next_sweep <= nNow) { // Sweep out expired orphan pool entries: int nErased = 0; auto nMinExpTime{nNow + ORPHAN_TX_EXPIRE_TIME - ORPHAN_TX_EXPIRE_INTERVAL}; @@ -135,7 +135,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng) } } // Sweep again 5 minutes after the next entry that expires in order to batch the linear scan. - nNextSweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL; + m_next_sweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL; if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan tx due to expiration\n", nErased); } while (m_orphans.size() > max_orphans) diff --git a/src/txorphanage.h b/src/txorphanage.h index 2da85828690e3..3054396b2d9c5 100644 --- a/src/txorphanage.h +++ b/src/txorphanage.h @@ -107,7 +107,7 @@ class TxOrphanage { int EraseTxNoLock(const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex); /** Timestamp for the next scheduled sweep of expired orphans */ - NodeSeconds nNextSweep GUARDED_BY(m_mutex){0s}; + NodeSeconds m_next_sweep GUARDED_BY(m_mutex){0s}; }; #endif // BITCOIN_TXORPHANAGE_H