Skip to content

Commit 43e813c

Browse files
committed
Merge bitcoin/bitcoin#26387: p2p: TryLowWorkHeadersSync follow-ups
784b023 [net processing] Simplify use of IsContinuationOfLowWorkHeadersSync in TryLowWorkHeaderSync (dergoegge) e891aab [net processing] Fixup TryLowWorkHeadersSync comment (dergoegge) Pull request description: See bitcoin/bitcoin#26355 (comment) and bitcoin/bitcoin#26355 (comment) ACKs for top commit: hernanmarino: ACK 784b023 brunoerg: crACK 784b023 mzumsande: ACK 784b023 Tree-SHA512: b47ac0d78a09ca3a1806e38c5d2e2fcf1e5f0668f202450b5079c5cb168e168ac6828c0948d23f3610696375134986d75ef3c6098858173023bcb743aec8004c
2 parents 4766cd1 + 784b023 commit 43e813c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,8 @@ class PeerManagerImpl final : public PeerManager
638638
* @param[in] chain_start_header Where these headers connect in our index.
639639
* @param[in,out] headers The headers to be processed.
640640
*
641-
* @return True if chain was low work and a headers sync was
642-
* initiated (and headers will be empty after calling); false
643-
* otherwise.
641+
* @return True if chain was low work (headers will be empty after
642+
* calling); false otherwise.
644643
*/
645644
bool TryLowWorkHeadersSync(Peer& peer, CNode& pfrom,
646645
const CBlockIndex* chain_start_header,
@@ -2563,14 +2562,10 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
25632562
peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(),
25642563
chain_start_header, minimum_chain_work));
25652564

2566-
// Now a HeadersSyncState object for tracking this synchronization is created,
2567-
// process the headers using it as normal.
2568-
if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers)) {
2569-
// Something went wrong, reset the headers sync.
2570-
peer.m_headers_sync.reset(nullptr);
2571-
LOCK(m_headers_presync_mutex);
2572-
m_headers_presync_stats.erase(peer.m_id);
2573-
}
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);
25742569
} else {
25752570
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
25762571
}

0 commit comments

Comments
 (0)