mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 12:37:16 +00:00
9f1cc40c89
* changed syncmode flag to snapshots flag * using boolT * Remove syncmode concept * Add mumbai Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
40 lines
951 B
Go
40 lines
951 B
Go
package snap
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
|
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
|
)
|
|
|
|
var (
|
|
blockSnapshotEnabledKey = []byte("blocksSnapshotEnabled")
|
|
)
|
|
|
|
func Enabled(tx kv.Getter) (bool, error) {
|
|
return kv.GetBool(tx, kv.DatabaseInfo, blockSnapshotEnabledKey)
|
|
}
|
|
|
|
func EnsureNotChanged(tx kv.GetPut, cfg ethconfig.Snapshot) (bool, bool, error) {
|
|
ok, v, err := kv.EnsureNotChangedBool(tx, kv.DatabaseInfo, blockSnapshotEnabledKey, cfg.Enabled)
|
|
if err != nil {
|
|
return false, false, err
|
|
}
|
|
if !ok {
|
|
return false, v, nil
|
|
}
|
|
return true, false, 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
|
|
}
|