mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
[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.
This commit is contained in:
parent
85e058b191
commit
b4e29f2436
1 changed files with 9 additions and 7 deletions
|
@ -159,10 +159,12 @@ static constexpr size_t MAX_ADDR_TO_SEND{1000};
|
|||
namespace {
|
||||
/** Blocks that are in flight, and that are in the queue to be downloaded. */
|
||||
struct QueuedBlock {
|
||||
/** Block hash */
|
||||
uint256 hash;
|
||||
const CBlockIndex* pindex; //!< Optional.
|
||||
bool fValidatedHeaders; //!< Whether this block has validated headers at the time of request.
|
||||
std::unique_ptr<PartiallyDownloadedBlock> partialBlock; //!< Optional, used for CMPCTBLOCK downloads
|
||||
/** BlockIndex. We must have this since we only request blocks when we've already validated the header. */
|
||||
const CBlockIndex* pindex;
|
||||
/** Optional, used for CMPCTBLOCK downloads */
|
||||
std::unique_ptr<PartiallyDownloadedBlock> partialBlock;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -764,8 +766,8 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
|
|||
if (itInFlight != mapBlocksInFlight.end()) {
|
||||
CNodeState *state = State(itInFlight->second.first);
|
||||
assert(state != nullptr);
|
||||
state->nBlocksInFlightValidHeaders -= itInFlight->second.second->fValidatedHeaders;
|
||||
if (state->nBlocksInFlightValidHeaders == 0 && itInFlight->second.second->fValidatedHeaders) {
|
||||
state->nBlocksInFlightValidHeaders -= 1;
|
||||
if (state->nBlocksInFlightValidHeaders == 0) {
|
||||
// Last validated block on the queue was received.
|
||||
nPeersWithValidatedDownloads--;
|
||||
}
|
||||
|
@ -803,9 +805,9 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
|
|||
MarkBlockAsReceived(hash);
|
||||
|
||||
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(),
|
||||
{hash, pindex, pindex != nullptr, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)});
|
||||
{hash, pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)});
|
||||
state->nBlocksInFlight++;
|
||||
state->nBlocksInFlightValidHeaders += it->fValidatedHeaders;
|
||||
state->nBlocksInFlightValidHeaders += 1;
|
||||
if (state->nBlocksInFlight == 1) {
|
||||
// We're starting a block download (batch) from this peer.
|
||||
state->m_downloading_since = GetTime<std::chrono::microseconds>();
|
||||
|
|
Loading…
Add table
Reference in a new issue