netsync: remove unused headerList and checkpoint code
What changed, and why it matters
This commit is a routine cleanup that removes leftover code for a 'headers-first' download mode and checkpoint tracking that is no longer used. There is no security issue here; it simply deletes unused fields and helper functions to make the code smaller and easier to maintain.
No security action needed. Reviewers may verify that no remaining callers reference the removed fields or functions, which the diff already confirms.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the headerList, startHeader, and nextCheckpoint fields from SyncManager, the resetHeaderState helper, and the container/list import. It also removes initialization and reset logic tied to headers-first sync and checkpoints. The remaining code only keeps the DisableCheckpoints informational log. This is a straightforward dead-code removal with no functional behavior change to active sync paths.
Changed components
netsync/manager.goInspect captured patch +1 / −35
diff --git a/netsync/manager.go b/netsync/manager.go
index 1f8b9d1..9f50144 100644
--- a/netsync/manager.go
+++ b/netsync/manager.go
@@ -5,7 +5,6 @@
package netsync
import (
- "container/list"
"math/rand"
"net"
"sync"
@@ -200,30 +199,11 @@ type SyncManager struct {
// The following fields are used for headers-first mode.
headersFirstMode bool
- headerList *list.List
- startHeader *list.Element
- nextCheckpoint *chaincfg.Checkpoint
// An optional fee estimator.
feeEstimator *mempool.FeeEstimator
}
-// resetHeaderState sets the headers-first mode state to values appropriate for
-// syncing from a new peer.
-func (sm *SyncManager) resetHeaderState(newestHash *chainhash.Hash, newestHeight int32) {
- sm.headersFirstMode = false
- sm.headerList.Init()
- sm.startHeader = nil
-
- // When there is a next checkpoint, add an entry for the latest known
- // block into the header pool. This allows the next downloaded header
- // to prove it links to the chain properly.
- if sm.nextCheckpoint != nil {
- node := headerNode{height: newestHeight, hash: newestHash}
- sm.headerList.PushBack(&node)
- }
-}
-
// findNextHeaderCheckpoint returns the next checkpoint after the passed height.
// It returns nil when there is not one either because the height is already
// later than the final checkpoint or some other reason such as disabled
@@ -585,12 +565,6 @@ func (sm *SyncManager) updateSyncPeer(dcSyncPeer bool) {
sm.syncPeer.Disconnect()
}
- // Reset any header state before we choose our next active sync peer.
- if sm.headersFirstMode {
- best := sm.chain.BestSnapshot()
- sm.resetHeaderState(&best.Hash, best.Height)
- }
-
sm.syncPeer = nil
sm.startSync()
}
@@ -1667,19 +1641,11 @@ func New(config *Config) (*SyncManager, error) {
peerStates: make(map[*peerpkg.Peer]*peerSyncState),
progressLogger: newBlockProgressLogger("Processed", log),
msgChan: make(chan interface{}, config.MaxPeers*3),
- headerList: list.New(),
quit: make(chan struct{}),
feeEstimator: config.FeeEstimator,
}
- best := sm.chain.BestSnapshot()
- if !config.DisableCheckpoints {
- // Initialize the next checkpoint based on the current height.
- sm.nextCheckpoint = sm.findNextHeaderCheckpoint(best.Height)
- if sm.nextCheckpoint != nil {
- sm.resetHeaderState(&best.Hash, best.Height)
- }
- } else {
+ if config.DisableCheckpoints {
log.Info("Checkpoints are disabled")
}
Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.