MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / findCommonAncestor

Method findCommonAncestor

src/node/interfaces.cpp:630–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628 return FillBlock(ancestor, ancestor_out, lock, chainman().ActiveChain(), chainman().m_blockman);
629 }
630 bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
631 {
632 WAIT_LOCK(cs_main, lock);
633 const CChain& active = chainman().ActiveChain();
634 const CBlockIndex* block1 = chainman().m_blockman.LookupBlockIndex(block_hash1);
635 const CBlockIndex* block2 = chainman().m_blockman.LookupBlockIndex(block_hash2);
636 const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
637 // Using & instead of && below to avoid short circuiting and leaving
638 // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
639 // compiler warnings.
640 return int{FillBlock(ancestor, ancestor_out, lock, active, chainman().m_blockman)} &
641 int{FillBlock(block1, block1_out, lock, active, chainman().m_blockman)} &
642 int{FillBlock(block2, block2_out, lock, active, chainman().m_blockman)};
643 }
644 void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
645 double guessVerificationProgress(const uint256& block_hash) override
646 {

Callers 2

listsinceblockFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls 2

LastCommonAncestorFunction · 0.85
LookupBlockIndexMethod · 0.80

Tested by 1

BOOST_FIXTURE_TEST_CASEFunction · 0.64