From 9aa4df467c7815697da206f3f06edde3c6afdec8 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 14 Apr 2025 13:42:00 +0200 Subject: [PATCH] core: move pruning init a bit earlier --- core/blockchain.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 242cadc4ac..901a93315a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -534,6 +534,12 @@ func (bc *BlockChain) loadLastState() error { } bc.hc.SetCurrentHeader(headHeader) + // Initialize history pruning. + latest := max(headBlock.NumberU64(), headHeader.Number.Uint64()) + if err := bc.initializeHistoryPruning(latest); err != nil { + return err + } + // Restore the last known head snap block bc.currentSnapBlock.Store(headBlock.Header()) headFastBlockGauge.Update(int64(headBlock.NumberU64())) @@ -557,11 +563,6 @@ func (bc *BlockChain) loadLastState() error { } } - // Initialize history pruning. - if err := bc.initializeHistoryPruning(headBlock.NumberU64()); err != nil { - return err - } - // Issue a status log for the user var ( currentSnapBlock = bc.CurrentSnapBlock()