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