Skip to content

Commit 5048465

Browse files
committed
Merge pull request #5662
00dcaf4 Change download logic to allow calling getheaders/getdata on inbound peers (Suhas Daftuar)
2 parents 6364408 + 00dcaf4 commit 5048465

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
@@ -4839,9 +4839,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
48394839
if (pindexBestHeader == NULL)
48404840
pindexBestHeader = chainActive.Tip();
48414841
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.
4842-
if (!state.fSyncStarted && !pto->fClient && fFetch && !fImporting && !fReindex) {
4842+
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
48434843
// Only actively request headers from a single peer, unless we're close to today.
4844-
if (nSyncStarted == 0 || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
4844+
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
48454845
state.fSyncStarted = true;
48464846
nSyncStarted++;
48474847
CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader;
@@ -4929,7 +4929,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
49294929
// Message: getdata (blocks)
49304930
//
49314931
vector<CInv> vGetData;
4932-
if (!pto->fDisconnect && !pto->fClient && fFetch && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
4932+
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
49334933
vector<CBlockIndex*> vToDownload;
49344934
NodeId staller = -1;
49354935
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);

0 commit comments

Comments
 (0)