MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FindForkInGlobalIndex

Function FindForkInGlobalIndex

src/validation.cpp:285–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283} // anon namespace
284
285CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
286{
287 AssertLockHeld(cs_main);
288
289 // Find the latest block common to locator and chain - we expect that
290 // locator.vHave is sorted descending by height.
291 for (const uint256& hash : locator.vHave) {
292 CBlockIndex* pindex = LookupBlockIndex(hash);
293 if (pindex) {
294 if (chain.Contains(pindex))
295 return pindex;
296 if (pindex->GetAncestor(chain.Height()) == chain.Tip()) {
297 return chain.Tip();
298 }
299 }
300 }
301 return chain.Genesis();
302}
303
304std::unique_ptr<CCoinsViewDB> pcoinsdbview;
305std::unique_ptr<CCoinsViewCache> pcoinsTip;

Callers 3

ProcessMessageFunction · 0.85
CreateWalletFromFileMethod · 0.85
InitMethod · 0.85

Calls 6

LookupBlockIndexFunction · 0.85
GetAncestorMethod · 0.80
HeightMethod · 0.80
GenesisMethod · 0.80
ContainsMethod · 0.45
TipMethod · 0.45

Tested by

no test coverage detected