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

Method FindForkInGlobalIndex

src/validation.cpp:161–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
160
161CBlockIndex* CChainState::FindForkInGlobalIndex(const CBlockLocator& locator) const
162{
163 AssertLockHeld(cs_main);
164
165 // Find the latest block common to locator and chain - we expect that
166 // locator.vHave is sorted descending by height.
167 for (const uint256& hash : locator.vHave) {
168 CBlockIndex* pindex{m_blockman.LookupBlockIndex(hash)};
169 if (pindex) {
170 if (m_chain.Contains(pindex)) {
171 return pindex;
172 }
173 if (pindex->GetAncestor(m_chain.Height()) == m_chain.Tip()) {
174 return m_chain.Tip();
175 }
176 }
177 }
178 return m_chain.Genesis();
179}
180
181bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
182 const CCoinsViewCache& inputs, unsigned int flags, bool cacheSigStore,

Callers 3

ProcessMessageMethod · 0.80
InitMethod · 0.80
findLocatorForkMethod · 0.80

Calls 6

LookupBlockIndexMethod · 0.80
GetAncestorMethod · 0.80
HeightMethod · 0.80
GenesisMethod · 0.80
ContainsMethod · 0.45
TipMethod · 0.45

Tested by

no test coverage detected