What changed, and why it matters
This commit is a simple rename of an internal variable from 'headersFirstMode' to 'ibdMode' (short for 'initial block download mode') and updates related comments. No behavior of the Bitcoin node software changes; it is purely a code clarity and naming improvement.
No security action needed. Treat as a normal non-security refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames the SyncManager struct field headersFirstMode to ibdMode and updates all references in netsync/manager.go and netsync/manager_test.go, along with associated comments. The logic, conditions, and control flow remain identical. There are no functional, cryptographic, or network protocol changes.
Changed components
netsync/manager.gonetsync/manager_test.goInspect captured patch +17 / −17
diff --git a/netsync/manager.go b/netsync/manager.go
index 9f50144..44c5fac 100644
--- a/netsync/manager.go
+++ b/netsync/manager.go
@@ -23,8 +23,8 @@ import (
const (
// minInFlightBlocks is the minimum number of blocks that should be
- // in the request queue for headers-first mode before requesting
- // more.
+ // in the request queue for the initial block download mode before
+ // requesting more.
minInFlightBlocks = 10
// maxRejectedTxns is the maximum number of rejected transactions
@@ -197,8 +197,8 @@ type SyncManager struct {
peerStates map[*peerpkg.Peer]*peerSyncState
lastProgressTime time.Time
- // The following fields are used for headers-first mode.
- headersFirstMode bool
+ // The following fields are used for the initial block download mode.
+ ibdMode bool
// An optional fee estimator.
feeEstimator *mempool.FeeEstimator
@@ -288,7 +288,7 @@ func (sm *SyncManager) fetchHeaders() {
bestPeer.PushGetHeadersMsg(locator, &zeroHash)
- sm.headersFirstMode = true
+ sm.ibdMode = true
sm.syncPeer = bestPeer
}
@@ -665,7 +665,7 @@ func (sm *SyncManager) checkHeadersList(blockHash *chainhash.Hash) (
bool, blockchain.BehaviorFlags) {
// Always return false and BFNone if we're not in ibd mode.
- if !sm.headersFirstMode {
+ if !sm.ibdMode {
return false, blockchain.BFNone
}
@@ -834,10 +834,10 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
}
}
- // If we are not in the headers-first mode, it's a good time to
+ // If we are not in the initial block download mode, it's a good time to
// periodically flush the blockchain cache because we don't expect new
// blocks immediately. After that, there is nothing more to do.
- if !sm.headersFirstMode {
+ if !sm.ibdMode {
if err := sm.chain.FlushUtxoCache(blockchain.FlushPeriodic); err != nil {
log.Errorf("Error while flushing the blockchain cache: %v", err)
}
@@ -869,7 +869,7 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
log.Infof("Finished the initial block download and "+
"caught up to block %v(%v) -- now listening to blocks.",
bmsg.block.Hash(), bmsg.block.Height())
- sm.headersFirstMode = false
+ sm.ibdMode = false
}
}
@@ -961,8 +961,8 @@ func (sm *SyncManager) buildBlockRequest(peer *peerpkg.Peer) *wire.MsgGetData {
}
// handleHeadersMsg handles block header messages from all peers. Headers are
-// requested when performing a headers-first sync and are propagated by peers
-// once the headers-first sync is complete.
+// requested when performing the ibd and are propagated by peers once the ibd
+// is complete.
func (sm *SyncManager) handleHeadersMsg(hmsg *headersMsg) {
peer := hmsg.peer
_, exists := sm.peerStates[peer]
@@ -994,7 +994,7 @@ func (sm *SyncManager) handleHeadersMsg(hmsg *headersMsg) {
}
bestHash, bestHeight := sm.chain.BestHeader()
- if sm.headersFirstMode {
+ if sm.ibdMode {
if sm.syncPeer == nil {
// Return if we've disconnected from the syncPeer.
return
@@ -1166,8 +1166,8 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
// for the peer.
peer.AddKnownInventory(iv)
- // Ignore inventory when we're in headers-first mode.
- if sm.headersFirstMode {
+ // Ignore inventory when we're in the initial block download mode.
+ if sm.ibdMode {
continue
}
diff --git a/netsync/manager_test.go b/netsync/manager_test.go
index ddfa3b8..177d0c5 100644
--- a/netsync/manager_test.go
+++ b/netsync/manager_test.go
@@ -213,15 +213,15 @@ func TestCheckHeadersList(t *testing.T) {
continue
}
- // Make sure that when the headers-first mode is off, we always get
+ // Make sure that when the ibd mode is off, we always get
// false and BFNone.
- sm.headersFirstMode = false
+ sm.ibdMode = false
isCheckpoint, gotFlags := sm.checkHeadersList(hash)
require.Equal(t, false, isCheckpoint)
require.Equal(t, blockchain.BFNone, gotFlags)
// Now check that the test values are correct.
- sm.headersFirstMode = true
+ sm.ibdMode = true
isCheckpoint, gotFlags = sm.checkHeadersList(hash)
require.Equal(t, test.isCheckpointBlock, isCheckpoint)
require.Equal(t, test.behaviorFlags, gotFlags)
Why this scored 15/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.