@@ -1473,30 +1473,41 @@ void PeerManagerImpl::FindNextBlocks(std::vector<const CBlockIndex*>& vBlocks, c
1473
1473
// We consider the chain that this peer is on invalid.
1474
1474
return ;
1475
1475
}
1476
+
1476
1477
if (!CanServeWitnesses (peer) && DeploymentActiveAt (*pindex, m_chainman, Consensus::DEPLOYMENT_SEGWIT)) {
1477
1478
// We wouldn't download this block or its descendants from this peer.
1478
1479
return ;
1479
1480
}
1481
+
1480
1482
if (pindex->nStatus & BLOCK_HAVE_DATA || (activeChain && activeChain->Contains (pindex))) {
1481
- if (activeChain && pindex->HaveNumChainTxs ())
1483
+ if (activeChain && pindex->HaveNumChainTxs ()) {
1482
1484
state->pindexLastCommonBlock = pindex;
1483
- } else if (!IsBlockRequested (pindex->GetBlockHash ())) {
1484
- // The block is not already downloaded, and not yet in flight.
1485
- if (pindex->nHeight > nWindowEnd) {
1486
- // We reached the end of the window.
1487
- if (vBlocks.size () == 0 && waitingfor != peer.m_id ) {
1488
- // We aren't able to fetch anything, but we would be if the download window was one larger.
1489
- if (nodeStaller) *nodeStaller = waitingfor;
1490
- }
1491
- return ;
1492
1485
}
1493
- vBlocks.push_back (pindex);
1494
- if (vBlocks.size () == count) {
1495
- return ;
1486
+ continue ;
1487
+ }
1488
+
1489
+ // Is block in-flight?
1490
+ if (IsBlockRequested (pindex->GetBlockHash ())) {
1491
+ if (waitingfor == -1 ) {
1492
+ // This is the first already-in-flight block.
1493
+ waitingfor = mapBlocksInFlight.lower_bound (pindex->GetBlockHash ())->second .first ;
1496
1494
}
1497
- } else if (waitingfor == -1 ) {
1498
- // This is the first already-in-flight block.
1499
- waitingfor = mapBlocksInFlight.lower_bound (pindex->GetBlockHash ())->second .first ;
1495
+ continue ;
1496
+ }
1497
+
1498
+ // The block is not already downloaded, and not yet in flight.
1499
+ if (pindex->nHeight > nWindowEnd) {
1500
+ // We reached the end of the window.
1501
+ if (vBlocks.size () == 0 && waitingfor != peer.m_id ) {
1502
+ // We aren't able to fetch anything, but we would be if the download window was one larger.
1503
+ if (nodeStaller) *nodeStaller = waitingfor;
1504
+ }
1505
+ return ;
1506
+ }
1507
+
1508
+ vBlocks.push_back (pindex);
1509
+ if (vBlocks.size () == count) {
1510
+ return ;
1500
1511
}
1501
1512
}
1502
1513
}
0 commit comments