@@ -5370,28 +5370,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
53705370 if (inv.type == MSG_BLOCK) {
53715371 UpdateBlockAvailability (pfrom->GetId (), inv.hash );
53725372 if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count (inv.hash )) {
5373- // First request the headers preceding the announced block. In the normal fully-synced
5374- // case where a new block is announced that succeeds the current tip (no reorganization),
5375- // there are no such headers.
5376- // Secondly, and only when we are close to being synced, we request the announced block directly,
5377- // to avoid an extra round-trip. Note that we must *first* ask for the headers, so by the
5378- // time the block arrives, the header chain leading up to it is already validated. Not
5379- // doing this will result in the received block being rejected as an orphan in case it is
5380- // not a direct successor.
5373+ // We used to request the full block here, but since headers-announcements are now the
5374+ // primary method of announcement on the network, and since, in the case that a node
5375+ // fell back to inv we probably have a reorg which we should get the headers for first,
5376+ // we now only provide a getheaders response here. When we receive the headers, we will
5377+ // then ask for the blocks we need.
53815378 connman.PushMessage (pfrom, NetMsgType::GETHEADERS, chainActive.GetLocator (pindexBestHeader), inv.hash );
5382- CNodeState *nodestate = State (pfrom->GetId ());
5383- if (CanDirectFetch (chainparams.GetConsensus ()) &&
5384- nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER &&
5385- (!IsWitnessEnabled (chainActive.Tip (), chainparams.GetConsensus ()) || State (pfrom->GetId ())->fHaveWitness )) {
5386- inv.type |= nFetchFlags;
5387- if (nodestate->fSupportsDesiredCmpctVersion )
5388- vToFetch.push_back (CInv (MSG_CMPCT_BLOCK, inv.hash ));
5389- else
5390- vToFetch.push_back (inv);
5391- // Mark block as in flight already, even though the actual "getdata" message only goes out
5392- // later (within the same cs_main lock, though).
5393- MarkBlockAsInFlight (pfrom->GetId (), inv.hash , chainparams.GetConsensus ());
5394- }
53955379 LogPrint (" net" , " getheaders (%d) %s to peer=%d\n " , pindexBestHeader->nHeight , inv.hash .ToString (), pfrom->id );
53965380 }
53975381 }
0 commit comments