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

Method findCommonAncestor

src/node/interfaces.cpp:530–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528 return FillBlock(ancestor, ancestor_out, lock, active);
529 }
530 bool findCommonAncestor(const uint256& block_hash1, const uint256& block_hash2, const FoundBlock& ancestor_out, const FoundBlock& block1_out, const FoundBlock& block2_out) override
531 {
532 WAIT_LOCK(cs_main, lock);
533 const CChain& active = Assert(m_node.chainman)->ActiveChain();
534 const CBlockIndex* block1 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash1);
535 const CBlockIndex* block2 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash2);
536 const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
537 // Using & instead of && below to avoid short circuiting and leaving
538 // output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
539 // compiler warnings.
540 return int{FillBlock(ancestor, ancestor_out, lock, active)} &
541 int{FillBlock(block1, block1_out, lock, active)} &
542 int{FillBlock(block2, block2_out, lock, active)};
543 }
544 void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
545 double guessVerificationProgress(const uint256& block_hash) override
546 {

Callers 2

listsinceblockFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 3

LastCommonAncestorFunction · 0.85
FillBlockFunction · 0.85
LookupBlockIndexMethod · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64