Skip to content

Commit 784b023

Browse files
committed
[net processing] Simplify use of IsContinuationOfLowWorkHeadersSync in TryLowWorkHeaderSync
`m_headers_sync` is already reset in IsContinuationOfLowWorkHeadersSync if there is a failure, so there is no need to also reset in TryLowWorkHeaderSync.
1 parent e891aab commit 784b023

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,14 +2562,10 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
25622562
peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(),
25632563
chain_start_header, minimum_chain_work));
25642564

2565-
// Now a HeadersSyncState object for tracking this synchronization is created,
2566-
// process the headers using it as normal.
2567-
if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers)) {
2568-
// Something went wrong, reset the headers sync.
2569-
peer.m_headers_sync.reset(nullptr);
2570-
LOCK(m_headers_presync_mutex);
2571-
m_headers_presync_stats.erase(peer.m_id);
2572-
}
2565+
// Now a HeadersSyncState object for tracking this synchronization
2566+
// is created, process the headers using it as normal. Failures are
2567+
// handled inside of IsContinuationOfLowWorkHeadersSync.
2568+
(void)IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers);
25732569
} else {
25742570
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
25752571
}

0 commit comments

Comments
 (0)