From 0d5d0b4be34598b3fefd98eb7a9579265465a268 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 1 Apr 2026 20:50:58 +0200 Subject: [PATCH] minor improvements --- core/blockchain.go | 11 +++++++---- core/blockchain_reader.go | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f9e4d2548d..085c025fc8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -728,10 +728,12 @@ func (bc *BlockChain) loadLastState() error { // initializeHistoryPruning sets bc.historyPrunePoint based on actual DB state. func (bc *BlockChain) initializeHistoryPruning(latest uint64) error { - freezerTail, _ := bc.db.Tail(rawdb.ChainFreezerBlockDataGroup) - policy := bc.cfg.HistoryPolicy + var ( + freezerTail, _ = bc.db.Tail(rawdb.ChainFreezerBlockDataGroup) + policy = bc.cfg.HistoryPolicy + target uint64 + ) // Compute the current prune target from the policy. - var target uint64 switch policy.Mode { case history.KeepAll: if freezerTail > 0 { @@ -747,8 +749,9 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error { case history.KeepRecent: head := bc.CurrentBlock() if head == nil || head.Number.Uint64() <= policy.Window { - // Chain too short for pruning. Record actual DB state. if freezerTail > 0 { + // Chain too short for pruning. Record actual DB state. + log.Warn("Chain too short for pruning", "tail", freezerTail, "window", policy.Window) bc.updateHistoryPrunePoint(freezerTail) } return nil diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 0eb7a9345d..d9a5f05391 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -505,7 +505,7 @@ func (bc *BlockChain) StateIndexProgress() (uint64, uint64, error) { return bc.triedb.IndexProgress() } -// HistoryPruningCutoff returns the actual history pruning point based on DB state. +// HistoryPruningCutoff returns the history pruning point based on DB state. // Blocks before this are not available in the database. func (bc *BlockChain) HistoryPruningCutoff() (uint64, common.Hash) { pt := bc.historyPrunePoint.Load()