@@ -159,10 +159,12 @@ static constexpr size_t MAX_ADDR_TO_SEND{1000};
159
159
namespace {
160
160
/* * Blocks that are in flight, and that are in the queue to be downloaded. */
161
161
struct QueuedBlock {
162
+ /* * Block hash */
162
163
uint256 hash;
163
- const CBlockIndex* pindex; // !< Optional.
164
- bool fValidatedHeaders ; // !< Whether this block has validated headers at the time of request.
165
- std::unique_ptr<PartiallyDownloadedBlock> partialBlock; // !< Optional, used for CMPCTBLOCK downloads
164
+ /* * BlockIndex. We must have this since we only request blocks when we've already validated the header. */
165
+ const CBlockIndex* pindex;
166
+ /* * Optional, used for CMPCTBLOCK downloads */
167
+ std::unique_ptr<PartiallyDownloadedBlock> partialBlock;
166
168
};
167
169
168
170
/* *
@@ -764,8 +766,8 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
764
766
if (itInFlight != mapBlocksInFlight.end ()) {
765
767
CNodeState *state = State (itInFlight->second .first );
766
768
assert (state != nullptr );
767
- state->nBlocksInFlightValidHeaders -= itInFlight-> second . second -> fValidatedHeaders ;
768
- if (state->nBlocksInFlightValidHeaders == 0 && itInFlight-> second . second -> fValidatedHeaders ) {
769
+ state->nBlocksInFlightValidHeaders -= 1 ;
770
+ if (state->nBlocksInFlightValidHeaders == 0 ) {
769
771
// Last validated block on the queue was received.
770
772
nPeersWithValidatedDownloads--;
771
773
}
@@ -803,9 +805,9 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
803
805
MarkBlockAsReceived (hash);
804
806
805
807
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight .insert (state->vBlocksInFlight .end (),
806
- {hash, pindex, pindex != nullptr , std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock (&m_mempool) : nullptr )});
808
+ {hash, pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock (&m_mempool) : nullptr )});
807
809
state->nBlocksInFlight ++;
808
- state->nBlocksInFlightValidHeaders += it-> fValidatedHeaders ;
810
+ state->nBlocksInFlightValidHeaders += 1 ;
809
811
if (state->nBlocksInFlight == 1 ) {
810
812
// We're starting a block download (batch) from this peer.
811
813
state->m_downloading_since = GetTime<std::chrono::microseconds>();
0 commit comments