MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / operator()

Method operator()

src/blockheaderprocessor.cpp:36–66  ·  view source on GitHub ↗

maybeAnnouncement: Header *might* have been received as a block announcement.

Source from the content-addressed store, hash-verified

34
35// maybeAnnouncement: Header *might* have been received as a block announcement.
36CBlockIndex* DefaultHeaderProcessor::operator()(const std::vector<CBlockHeader>& headers,
37 bool peerSentMax,
38 bool maybeAnnouncement)
39{
40 CBlockIndex* pindexLast = acceptHeaders(headers);
41
42 NodeStatePtr(pfrom->id)->unconnectingHeaders = 0;
43
44 if (pindexLast)
45 UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash());
46
47 if (peerSentMax && pindexLast) {
48 // Headers message had its maximum size; the peer may have more headers.
49 // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue
50 // from there instead.
51 LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight);
52 pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256());
53 }
54
55 if (pindexLast && maybeAnnouncement && hasEqualOrMoreWork(pindexLast)) {
56
57 std::vector<CBlockIndex*> toFetch = findMissingBlocks(pindexLast);
58
59 // We may or may not start downloading the blocks
60 // from this peer now.
61 suggestDownload(toFetch, pindexLast);
62 }
63
64 checkBlockIndex();
65 return pindexLast;
66}
67
68CBlockIndex* DefaultHeaderProcessor::acceptHeaders(
69 const std::vector<CBlockHeader>& headers) {

Callers

nothing calls this directly

Calls 7

NodeStatePtrClass · 0.85
UpdateBlockAvailabilityFunction · 0.85
GetIdMethod · 0.80
PushMessageMethod · 0.80
GetLocatorMethod · 0.80
uint256Class · 0.70
GetBlockHashMethod · 0.45

Tested by

no test coverage detected