maybeAnnouncement: Header *might* have been received as a block announcement.
| 34 | |
| 35 | // maybeAnnouncement: Header *might* have been received as a block announcement. |
| 36 | CBlockIndex* 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 | |
| 68 | CBlockIndex* DefaultHeaderProcessor::acceptHeaders( |
| 69 | const std::vector<CBlockHeader>& headers) { |
nothing calls this directly
no test coverage detected