[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.
This commit is contained in:
1 parent
e891aabf5a
commit
784b023191
1 file changed
+4
-8
@@ -2562,14 +2562,10 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
|
|||||||
peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(),
|
peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(),
|
||||||
chain_start_header, minimum_chain_work));
|
chain_start_header, minimum_chain_work));
|
||||||
|
|
||||||
// Now a HeadersSyncState object for tracking this synchronization is created,
|
// Now a HeadersSyncState object for tracking this synchronization
|
||||||
// process the headers using it as normal.
|
// is created, process the headers using it as normal. Failures are
|
||||||
if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers)) {
|
// handled inside of IsContinuationOfLowWorkHeadersSync.
|
||||||
// Something went wrong, reset the headers sync.
|
(void)IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers);
|
||||||
peer.m_headers_sync.reset(nullptr);
|
|
||||||
LOCK(m_headers_presync_mutex);
|
|
||||||
m_headers_presync_stats.erase(peer.m_id);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
|
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user