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

Method TryDownloadingHistoricalBlocks

src/net_processing.cpp:1456–1483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1454}
1455
1456void PeerManagerImpl::TryDownloadingHistoricalBlocks(const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, const CBlockIndex *from_tip, const CBlockIndex* target_block)
1457{
1458 Assert(from_tip);
1459 Assert(target_block);
1460
1461 if (vBlocks.size() >= count) {
1462 return;
1463 }
1464
1465 vBlocks.reserve(count);
1466 CNodeState *state = Assert(State(peer.m_id));
1467
1468 if (state->pindexBestKnownBlock == nullptr || state->pindexBestKnownBlock->GetAncestor(target_block->nHeight) != target_block) {
1469 // This peer can't provide us the complete series of blocks leading up to the
1470 // assumeutxo snapshot base.
1471 //
1472 // Presumably this peer's chain has less work than our ActiveChain()'s tip, or else we
1473 // will eventually crash when we try to reorg to it. Let other logic
1474 // deal with whether we disconnect this peer.
1475 //
1476 // TODO at some point in the future, we might choose to request what blocks
1477 // this peer does have from the historical chain, despite it not having a
1478 // complete history beneath the snapshot base.
1479 return;
1480 }
1481
1482 FindNextBlocks(vBlocks, peer, state, from_tip, count, std::min<int>(from_tip->nHeight + BLOCK_DOWNLOAD_WINDOW, target_block->nHeight));
1483}
1484
1485void PeerManagerImpl::FindNextBlocks(std::vector<const CBlockIndex*>& vBlocks, const Peer& peer, CNodeState *state, const CBlockIndex *pindexWalk, unsigned int count, int nWindowEnd, const CChain* activeChain, NodeId* nodeStaller)
1486{

Callers

nothing calls this directly

Calls 4

StateEnum · 0.70
sizeMethod · 0.45
reserveMethod · 0.45
GetAncestorMethod · 0.45

Tested by

no test coverage detected