Skip to content

Commit b4e29f2

Browse files
committed
[net processing] Remove QueuedBlock.fValidatedHeaders
Since headers-first syncing, we only ever request a block if we've already validated its headers. Therefore QueuedBlock.fValidatedHeaders is always set to true. Remove it.
1 parent 85e058b commit b4e29f2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ static constexpr size_t MAX_ADDR_TO_SEND{1000};
159159
namespace {
160160
/** Blocks that are in flight, and that are in the queue to be downloaded. */
161161
struct QueuedBlock {
162+
/** Block hash */
162163
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;
166168
};
167169

168170
/**
@@ -764,8 +766,8 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
764766
if (itInFlight != mapBlocksInFlight.end()) {
765767
CNodeState *state = State(itInFlight->second.first);
766768
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) {
769771
// Last validated block on the queue was received.
770772
nPeersWithValidatedDownloads--;
771773
}
@@ -803,9 +805,9 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
803805
MarkBlockAsReceived(hash);
804806

805807
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)});
807809
state->nBlocksInFlight++;
808-
state->nBlocksInFlightValidHeaders += it->fValidatedHeaders;
810+
state->nBlocksInFlightValidHeaders += 1;
809811
if (state->nBlocksInFlight == 1) {
810812
// We're starting a block download (batch) from this peer.
811813
state->m_downloading_since = GetTime<std::chrono::microseconds>();

0 commit comments

Comments
 (0)