core: move pruning init a bit earlier

This commit is contained in:
Felix Lange 2025-04-14 13:42:00 +02:00
parent 75fc954d96
commit 9aa4df467c

View file

@ -534,6 +534,12 @@ func (bc *BlockChain) loadLastState() error {
} }
bc.hc.SetCurrentHeader(headHeader) 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 // Restore the last known head snap block
bc.currentSnapBlock.Store(headBlock.Header()) bc.currentSnapBlock.Store(headBlock.Header())
headFastBlockGauge.Update(int64(headBlock.NumberU64())) 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 // Issue a status log for the user
var ( var (
currentSnapBlock = bc.CurrentSnapBlock() currentSnapBlock = bc.CurrentSnapBlock()