mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
32 lines
858 B
Go
32 lines
858 B
Go
|
package snapshotsynccli
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/ledgerwatch/erigon-lib/kv"
|
||
|
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
blockSnapshotEnabledKey = []byte("blocksSnapshotEnabled")
|
||
|
blockSnapshotRetireEnabledKey = []byte("blocksSnapshotRetireEnabled")
|
||
|
)
|
||
|
|
||
|
func EnsureNotChanged(tx kv.GetPut, cfg ethconfig.Snapshot) error {
|
||
|
ok, v, err := kv.EnsureNotChangedBool(tx, kv.DatabaseInfo, blockSnapshotEnabledKey, cfg.Enabled)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !ok {
|
||
|
return fmt.Errorf("node was started with --%s=%v, can't change it", ethconfig.FlagSnapshot, v)
|
||
|
}
|
||
|
ok, v, err = kv.EnsureNotChangedBool(tx, kv.DatabaseInfo, blockSnapshotRetireEnabledKey, cfg.RetireEnabled)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if !ok {
|
||
|
return fmt.Errorf("node was started with --%s=%v, can't change it", ethconfig.FlagSnapshotRetire, v)
|
||
|
}
|
||
|
return nil
|
||
|
}
|