mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Merge bitcoin/bitcoin#26387: p2p: TryLowWorkHeadersSync follow-ups
784b023191
[net processing] Simplify use of IsContinuationOfLowWorkHeadersSync in TryLowWorkHeaderSync (dergoegge)e891aabf5a
[net processing] Fixup TryLowWorkHeadersSync comment (dergoegge) Pull request description: See https://github.com/bitcoin/bitcoin/pull/26355#discussion_r1003561481 and https://github.com/bitcoin/bitcoin/pull/26355#discussion_r1004554187 ACKs for top commit: hernanmarino: ACK784b023191
brunoerg: crACK784b023191
mzumsande: ACK784b023191
Tree-SHA512: b47ac0d78a09ca3a1806e38c5d2e2fcf1e5f0668f202450b5079c5cb168e168ac6828c0948d23f3610696375134986d75ef3c6098858173023bcb743aec8004c
This commit is contained in:
commit
43e813cab2
1 changed files with 6 additions and 11 deletions
|
@ -638,9 +638,8 @@ private:
|
||||||
* @param[in] chain_start_header Where these headers connect in our index.
|
* @param[in] chain_start_header Where these headers connect in our index.
|
||||||
* @param[in,out] headers The headers to be processed.
|
* @param[in,out] headers The headers to be processed.
|
||||||
*
|
*
|
||||||
* @return True if chain was low work and a headers sync was
|
* @return True if chain was low work (headers will be empty after
|
||||||
* initiated (and headers will be empty after calling); false
|
* calling); false otherwise.
|
||||||
* otherwise.
|
|
||||||
*/
|
*/
|
||||||
bool TryLowWorkHeadersSync(Peer& peer, CNode& pfrom,
|
bool TryLowWorkHeadersSync(Peer& peer, CNode& pfrom,
|
||||||
const CBlockIndex* chain_start_header,
|
const CBlockIndex* chain_start_header,
|
||||||
|
@ -2563,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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue