diff --git a/src/avalanche/processor.h b/src/avalanche/processor.h --- a/src/avalanche/processor.h +++ b/src/avalanche/processor.h @@ -253,6 +253,9 @@ */ uint256 buildLocalSighash(CNode *pfrom) const; + bool isWorthPolling(const CBlockIndex *pindex) const + EXCLUSIVE_LOCKS_REQUIRED(cs_main); + friend struct ::avalanche::AvalancheTest; }; diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -35,23 +35,6 @@ std::unique_ptr g_avalanche; namespace avalanche { -static bool IsWorthPolling(const CBlockIndex *pindex) - EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - AssertLockHeld(cs_main); - - if (pindex->nStatus.isInvalid()) { - // No point polling invalid blocks. - return false; - } - - if (::ChainstateActive().IsBlockFinalized(pindex)) { - // There is no point polling finalized block. - return false; - } - - return true; -} - static bool VerifyProof(const Proof &proof, bilingual_str &error) { ProofValidationState proof_state; @@ -334,13 +317,13 @@ bool isAccepted; if (!pindex) { - // IsWorthPolling expects this to be non-null, so bail early. + // isWorthPolling expects this to be non-null, so bail early. return false; } { LOCK(cs_main); - if (!IsWorthPolling(pindex)) { + if (!isWorthPolling(pindex)) { // There is no point polling this block. return false; } @@ -516,7 +499,7 @@ continue; } - if (!IsWorthPolling(pindex)) { + if (!isWorthPolling(pindex)) { // There is no point polling this block. continue; } @@ -878,7 +861,7 @@ auto w = blockVoteRecords.getWriteView(); for (auto it = w->begin(); it != w->end();) { const CBlockIndex *pindex = it->first; - if (!IsWorthPolling(pindex)) { + if (!isWorthPolling(pindex)) { w->erase(it++); } else { ++it; @@ -909,4 +892,20 @@ return hasher.GetHash(); } +bool Processor::isWorthPolling(const CBlockIndex *pindex) const { + AssertLockHeld(cs_main); + + if (pindex->nStatus.isInvalid()) { + // No point polling invalid blocks. + return false; + } + + if (::ChainstateActive().IsBlockFinalized(pindex)) { + // There is no point polling finalized block. + return false; + } + + return true; +} + } // namespace avalanche