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

Method UpdateBlockAvailability

src/net_processing.cpp:1387–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1385}
1386
1387void PeerManagerImpl::UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
1388 CNodeState *state = State(nodeid);
1389 assert(state != nullptr);
1390
1391 ProcessBlockAvailability(nodeid);
1392
1393 const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(hash);
1394 if (pindex && pindex->nChainWork > 0) {
1395 // An actually better block was announced.
1396 if (state->pindexBestKnownBlock == nullptr || pindex->nChainWork >= state->pindexBestKnownBlock->nChainWork) {
1397 state->pindexBestKnownBlock = pindex;
1398 }
1399 } else {
1400 // An unknown block was announced; just assume that the latest one is the best one.
1401 state->hashLastUnknownBlock = hash;
1402 }
1403}
1404
1405// Logic for calculating which blocks to download from a given peer, given our current tip.
1406void PeerManagerImpl::FindNextBlocksToDownload(const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller)

Callers

nothing calls this directly

Calls 2

LookupBlockIndexMethod · 0.80
StateEnum · 0.70

Tested by

no test coverage detected