mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 12:01:20 +00:00
9b47daee44
* change syncmode default to snap sync * save
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package snapshotsynccli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
|
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
|
)
|
|
|
|
var (
|
|
blockSnapshotEnabledKey = []byte("blocksSnapshotEnabled")
|
|
)
|
|
|
|
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 {
|
|
if v {
|
|
return fmt.Errorf("we recently changed default of --syncmode flag, please add flag --syncmode=snap")
|
|
} else {
|
|
return fmt.Errorf("we recently changed default of --syncmode flag, please add flag --syncmode=fast")
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ForceSetFlags - if you know what you are doing
|
|
func ForceSetFlags(tx kv.GetPut, cfg ethconfig.Snapshot) error {
|
|
if cfg.Enabled {
|
|
if err := tx.Put(kv.DatabaseInfo, blockSnapshotEnabledKey, []byte{1}); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err := tx.Put(kv.DatabaseInfo, blockSnapshotEnabledKey, []byte{0}); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|