Skip to content

Commit 73a6d2b

Browse files
committed
validation: Pass in chainstate to IsCurrentForFeeEstimation
1 parent d1f932b commit 73a6d2b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/validation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,15 @@ static void LimitMempoolSize(CTxMemPool& pool, CCoinsViewCache& coins_cache, siz
344344
coins_cache.Uncache(removed);
345345
}
346346

347-
static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
347+
static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
348348
{
349349
AssertLockHeld(cs_main);
350-
if (::ChainstateActive().IsInitialBlockDownload())
350+
assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
351+
if (active_chainstate.IsInitialBlockDownload())
351352
return false;
352-
if (::ChainActive().Tip()->GetBlockTime() < count_seconds(GetTime<std::chrono::seconds>() - MAX_FEE_ESTIMATION_TIP_AGE))
353+
if (active_chainstate.m_chain.Tip()->GetBlockTime() < count_seconds(GetTime<std::chrono::seconds>() - MAX_FEE_ESTIMATION_TIP_AGE))
353354
return false;
354-
if (::ChainActive().Height() < pindexBestHeader->nHeight - 1)
355+
if (active_chainstate.m_chain.Height() < pindexBestHeader->nHeight - 1)
355356
return false;
356357
return true;
357358
}
@@ -1009,7 +1010,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
10091010
// - it's not being re-added during a reorg which bypasses typical mempool fee limits
10101011
// - the node is not behind
10111012
// - the transaction is not dependent on any other transactions in the mempool
1012-
bool validForFeeEstimation = !fReplacementTransaction && !bypass_limits && IsCurrentForFeeEstimation() && m_pool.HasNoInputsOf(tx);
1013+
bool validForFeeEstimation = !fReplacementTransaction && !bypass_limits && IsCurrentForFeeEstimation(::ChainstateActive()) && m_pool.HasNoInputsOf(tx);
10131014

10141015
// Store transaction in memory
10151016
m_pool.addUnchecked(*entry, setAncestors, validForFeeEstimation);

0 commit comments

Comments
 (0)