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

Method HandleUnconnectingHeaders

src/net_processing.cpp:2682–2699  ·  view source on GitHub ↗

* Special handling for unconnecting headers that might be part of a block * announcement. * * We'll send a getheaders message in response to try to connect the chain. */

Source from the content-addressed store, hash-verified

2680 * We'll send a getheaders message in response to try to connect the chain.
2681 */
2682void PeerManagerImpl::HandleUnconnectingHeaders(CNode& pfrom, Peer& peer,
2683 const std::vector<CBlockHeader>& headers)
2684{
2685 // Try to fill in the missing headers.
2686 const CBlockIndex* best_header{WITH_LOCK(cs_main, return m_chainman.m_best_header)};
2687 if (MaybeSendGetHeaders(pfrom, GetLocator(best_header), peer)) {
2688 LogDebug(BCLog::NET, "received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d)\n",
2689 headers[0].GetHash().ToString(),
2690 headers[0].hashPrevBlock.ToString(),
2691 best_header->nHeight,
2692 pfrom.GetId());
2693 }
2694
2695 // Set hashLastUnknownBlock for this peer, so that if we
2696 // eventually get the headers - even from a different peer -
2697 // we can use this peer to download.
2698 WITH_LOCK(cs_main, UpdateBlockAvailability(pfrom.GetId(), headers.back().GetHash()));
2699}
2700
2701bool PeerManagerImpl::CheckHeadersAreContinuous(const std::vector<CBlockHeader>& headers) const
2702{

Callers

nothing calls this directly

Calls 5

GetIdMethod · 0.80
GetLocatorFunction · 0.70
ToStringMethod · 0.45
GetHashMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected