Skip to content

Commit 4e90d2d

Browse files
committed
[net processing] Remove QueuedBlock.hash
It's redundant with CBlockIndex::GetBlockHash()
1 parent 156a19e commit 4e90d2d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ 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 */
163-
uint256 hash;
164162
/** BlockIndex. We must have this since we only request blocks when we've already validated the header. */
165163
const CBlockIndex* pindex;
166164
/** Optional, used for CMPCTBLOCK downloads */
@@ -803,7 +801,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
803801
MarkBlockAsReceived(hash);
804802

805803
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(),
806-
{hash, pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)});
804+
{pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)});
807805
state->nBlocksInFlight++;
808806
if (state->nBlocksInFlight == 1) {
809807
// We're starting a block download (batch) from this peer.
@@ -1129,7 +1127,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node)
11291127
nSyncStarted--;
11301128

11311129
for (const QueuedBlock& entry : state->vBlocksInFlight) {
1132-
mapBlocksInFlight.erase(entry.hash);
1130+
mapBlocksInFlight.erase(entry.pindex->GetBlockHash());
11331131
}
11341132
WITH_LOCK(g_cs_orphans, m_orphanage.EraseForPeer(nodeid));
11351133
m_txrequest.DisconnectedPeer(nodeid);
@@ -4714,7 +4712,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47144712
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
47154713
int nOtherPeersWithValidatedDownloads = m_peers_downloading_from - 1;
47164714
if (current_time > state.m_downloading_since + std::chrono::seconds{consensusParams.nPowTargetSpacing} * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) {
4717-
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->GetId());
4715+
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.pindex->GetBlockHash().ToString(), pto->GetId());
47184716
pto->fDisconnect = true;
47194717
return true;
47204718
}

0 commit comments

Comments
 (0)