aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2020-09-16 16:36:06 -0400
committerCarl Dong <contact@carldong.me>2021-02-18 14:43:28 -0500
commit73a6d2b7bea832fe24870dd7593c8fc1028e8d57 (patch)
tree337a6c8e7ff53110b9a3a7d8251b2cbb34b811dd /src/validation.cpp
parentd1f932b0b0685690e5142272a2ed6a21237fbf05 (diff)
downloadbitcoin-73a6d2b7bea832fe24870dd7593c8fc1028e8d57.tar.xz
validation: Pass in chainstate to IsCurrentForFeeEstimation
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 0225786183..d63a9e9a40 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -344,14 +344,15 @@ static void LimitMempoolSize(CTxMemPool& pool, CCoinsViewCache& coins_cache, siz
coins_cache.Uncache(removed);
}
-static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
+static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
AssertLockHeld(cs_main);
- if (::ChainstateActive().IsInitialBlockDownload())
+ assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
+ if (active_chainstate.IsInitialBlockDownload())
return false;
- if (::ChainActive().Tip()->GetBlockTime() < count_seconds(GetTime<std::chrono::seconds>() - MAX_FEE_ESTIMATION_TIP_AGE))
+ if (active_chainstate.m_chain.Tip()->GetBlockTime() < count_seconds(GetTime<std::chrono::seconds>() - MAX_FEE_ESTIMATION_TIP_AGE))
return false;
- if (::ChainActive().Height() < pindexBestHeader->nHeight - 1)
+ if (active_chainstate.m_chain.Height() < pindexBestHeader->nHeight - 1)
return false;
return true;
}
@@ -1009,7 +1010,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
// - it's not being re-added during a reorg which bypasses typical mempool fee limits
// - the node is not behind
// - the transaction is not dependent on any other transactions in the mempool
- bool validForFeeEstimation = !fReplacementTransaction && !bypass_limits && IsCurrentForFeeEstimation() && m_pool.HasNoInputsOf(tx);
+ bool validForFeeEstimation = !fReplacementTransaction && !bypass_limits && IsCurrentForFeeEstimation(::ChainstateActive()) && m_pool.HasNoInputsOf(tx);
// Store transaction in memory
m_pool.addUnchecked(*entry, setAncestors, validForFeeEstimation);