2022-01-22 04:18:24 +00:00
|
|
|
package snapshotsynccli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
|
|
|
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-16 02:57:48 +00:00
|
|
|
blockSnapshotEnabledKey = []byte("blocksSnapshotEnabled")
|
2022-01-22 04:18:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|