MCPcopy Create free account
hub / github.com/ElementsProject/elements / hasBlocks

Method hasBlocks

src/node/interfaces.cpp:550–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548 return GuessVerificationProgress(chainman().m_blockman.LookupBlockIndex(block_hash), Params().GetConsensus().nPowTargetSpacing);
549 }
550 bool hasBlocks(const uint256& block_hash, int min_height, std::optional<int> max_height) override
551 {
552 // hasBlocks returns true if all ancestors of block_hash in specified
553 // range have block data (are not pruned), false if any ancestors in
554 // specified range are missing data.
555 //
556 // For simplicity and robustness, min_height and max_height are only
557 // used to limit the range, and passing min_height that's too low or
558 // max_height that's too high will not crash or change the result.
559 LOCK(::cs_main);
560 if (CBlockIndex* block = chainman().m_blockman.LookupBlockIndex(block_hash)) {
561 if (max_height && block->nHeight >= *max_height) block = block->GetAncestor(*max_height);
562 for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev) {
563 // Check pprev to not segfault if min_height is too low
564 if (block->nHeight <= min_height || !block->pprev) return true;
565 }
566 }
567 return false;
568 }
569 RBFTransactionState isRBFOptIn(const CTransaction& tx) override
570 {
571 if (!m_node.mempool) return IsRBFOptInEmptyMempool(tx);

Callers 3

signblockFunction · 0.80
transactions.cppFile · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 2

LookupBlockIndexMethod · 0.80
GetAncestorMethod · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64