Skip to content

Commit 00dcaf4

Browse files
committed
Change download logic to allow calling getheaders/getdata on inbound peers
SendMessages will now call getheaders on both inbound and outbound peers, once the headers chain is close to synced. It will also try downloading blocks from inbound peers once we're out of initial block download (so inbound peers will participate in parallel block fetching for the last day or two of blocks being downloaded).
1 parent 446bb70 commit 00dcaf4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,9 +4459,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
44594459
if (pindexBestHeader == NULL)
44604460
pindexBestHeader = chainActive.Tip();
44614461
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
4462-
if (!state.fSyncStarted && !pto->fClient && fFetch && !fImporting && !fReindex) {
4462+
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
44634463
// Only actively request headers from a single peer, unless we're close to today.
4464-
if (nSyncStarted == 0 || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
4464+
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
44654465
state.fSyncStarted = true;
44664466
nSyncStarted++;
44674467
CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader;
@@ -4549,7 +4549,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
45494549
// Message: getdata (blocks)
45504550
//
45514551
vector<CInv> vGetData;
4552-
if (!pto->fDisconnect && !pto->fClient && fFetch && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
4552+
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
45534553
vector<CBlockIndex*> vToDownload;
45544554
NodeId staller = -1;
45554555
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);

0 commit comments

Comments
 (0)