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()