mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
Merge bitcoin/bitcoin#26382: [24.x] p2p: Handle IsContinuationOfLowWorkHeadersSync return value correctly when new headers sync is started
e23def8fcc
[net processing] Handle IsContinuationOfLowWorkHeadersSync return value correctly when new headers sync is started (dergoegge) Pull request description: Backport of #26355. ACKs for top commit: dergoegge: ACKe23def8fcc
stickies-v: ACKe23def8fcc
Tree-SHA512: 051ecb08f1f96557b5b6d01cc9d29a5dfabbb48afffd52cba662251c23277938fcbb6f207fc7575774ef627a9484ceb056cc75476861b920723c35c2f5da36c8
This commit is contained in:
commit
d22cc74837
1 changed files with 12 additions and 4 deletions
|
@ -2559,14 +2559,22 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
|
|||
|
||||
// Now a HeadersSyncState object for tracking this synchronization is created,
|
||||
// process the headers using it as normal.
|
||||
return IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers);
|
||||
if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers)) {
|
||||
// Something went wrong, reset the headers sync.
|
||||
peer.m_headers_sync.reset(nullptr);
|
||||
LOCK(m_headers_presync_mutex);
|
||||
m_headers_presync_stats.erase(peer.m_id);
|
||||
}
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
|
||||
// Since this is a low-work headers chain, no further processing is required.
|
||||
headers = {};
|
||||
return true;
|
||||
}
|
||||
|
||||
// The peer has not yet given us a chain that meets our work threshold,
|
||||
// so we want to prevent further processing of the headers in any case.
|
||||
headers = {};
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue