mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Delete old checkpoints in stateDB automatically
Introduce a constructor parameter for the StateDB called `keep`, which tells how many checkpoints to keep. When doing a new checkpoint, if the number of existing checkpoints exeeds `keep`, the oldest ones will be deleted.
This commit is contained in:
@@ -130,7 +130,13 @@ func NewNode(mode Mode, cfg *config.Node) (*Node, error) {
|
||||
}
|
||||
chainIDU16 := uint16(chainIDU64)
|
||||
|
||||
stateDB, err := statedb.NewStateDB(cfg.StateDB.Path, statedb.TypeSynchronizer, 32, chainIDU16)
|
||||
const safeStateDBKeep = 128
|
||||
if cfg.StateDB.Keep < safeStateDBKeep {
|
||||
return nil, tracerr.Wrap(fmt.Errorf("cfg.StateDB.Keep = %v < %v, which is unsafe",
|
||||
cfg.StateDB.Keep, safeStateDBKeep))
|
||||
}
|
||||
stateDB, err := statedb.NewStateDB(cfg.StateDB.Path, cfg.StateDB.Keep,
|
||||
statedb.TypeSynchronizer, 32, chainIDU16)
|
||||
if err != nil {
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user