Skip to content

Commit cd45c5d

Browse files
knstfanquake
andcommitted
Merge 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#26355 (comment) and bitcoin#26355 (comment) ACKs for top commit: hernanmarino: ACK 784b023 brunoerg: crACK 784b023 mzumsande: ACK 784b023 Tree-SHA512: b47ac0d78a09ca3a1806e38c5d2e2fcf1e5f0668f202450b5079c5cb168e168ac6828c0948d23f3610696375134986d75ef3c6098858173023bcb743aec8004c Co-authored-by: fanquake <fanquake@gmail.com>
1 parent 059034f commit cd45c5d

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

src/net_processing.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,8 @@ class PeerManagerImpl final : public PeerManager
818818
* @param[in] chain_start_header Where these headers connect in our index.
819819
* @param[in,out] headers The headers to be processed.
820820
*
821-
* @return True if chain was low work and a headers sync was
822-
* initiated (and headers will be empty after calling); false
823-
* otherwise.
821+
* @return True if chain was low work (headers will be empty after
822+
* calling); false otherwise.
824823
*/
825824
bool TryLowWorkHeadersSync(Peer& peer, CNode& pfrom,
826825
const CBlockIndex* chain_start_header,
@@ -3395,14 +3394,10 @@ bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlo
33953394
peer.m_headers_sync.reset(new HeadersSyncState(peer.m_id, m_chainparams.GetConsensus(),
33963395
chain_start_header, minimum_chain_work));
33973396

3398-
// Now a HeadersSyncState object for tracking this synchronization is created,
3399-
// process the headers using it as normal.
3400-
if (!IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers, uses_compressed)) {
3401-
// Something went wrong, reset the headers sync.
3402-
peer.m_headers_sync.reset(nullptr);
3403-
LOCK(m_headers_presync_mutex);
3404-
m_headers_presync_stats.erase(peer.m_id);
3405-
}
3397+
// Now a HeadersSyncState object for tracking this synchronization
3398+
// is created, process the headers using it as normal. Failures are
3399+
// handled inside of IsContinuationOfLowWorkHeadersSync.
3400+
(void)IsContinuationOfLowWorkHeadersSync(peer, pfrom, headers, uses_compressed);
34063401
} else {
34073402
LogPrint(BCLog::NET, "Ignoring low-work chain (height=%u) from peer=%d\n", chain_start_header->nHeight + headers.size(), pfrom.GetId());
34083403
}

0 commit comments

Comments
 (0)