mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #20222: refactor: CTxMempool constructor clean up
f15e780b9erefactor: Clean up CTxMemPool initializer list (Elle Mouton)e3310692d0refactor: Make CTxMemPool::m_check_ratio a const and a constructor argument (Elle Mouton)9d4b4b2c2crefactor: Avoid double to int cast for nCheckFrequency (Elle Mouton) Pull request description: This PR cleans up the CTxMemPool interface by including the ratio used to determine when a mempool sanity check should run in the constructor of CTxMempool instead of using nCheckFrequency which required a cast from a double to a uint32_t. Since nCheckFrequency (now called m_check_ratio) is set in the constructor and only every read from there after, it can be turned into a const and no longer needs to be guarded by the 'cs' lock. Since nCheckFrequency/m_check_ratio no longer needs to lock the 'cs' mutux, mutex lock line in the "CTxMempool::check" function can be moved below where the m_check_ratio variable is checked. Since the variable is 0 by default (meaning that "CTxMempool::check" will most likely not run its logic) this saves us from unnecessarily grabbing the lock. ACKs for top commit: jnewbery: utACKf15e780b9eMarcoFalke: ACKf15e780b9e👘 glozow: utACKf15e780b9etheStack: Code Review ACKf15e780b9eTree-SHA512: d83f3b5311ca128847b621e5e999c7e1bf0f4e6261d4cc090fb13e229a0f7eecd66ad997f654f50a838baf708d1515740aa3bffc244909a001d01fd5ae398b68
This commit is contained in:
@@ -141,8 +141,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||
|
||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||
|
||||
m_node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator);
|
||||
m_node.mempool->setSanityCheck(1.0);
|
||||
m_node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator, 1);
|
||||
|
||||
m_node.chainman = &::g_chainman;
|
||||
m_node.chainman->InitializeChainstate(*m_node.mempool);
|
||||
|
||||
Reference in New Issue
Block a user