mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
syncmode changes (#4334)
* log syncmode * little comment * ops * calling log in correct place * got rid of error instead we warn * no return
This commit is contained in:
parent
ea9e547be5
commit
bc21ab9d97
@ -1104,10 +1104,7 @@ var _allSnapshotsSingleton *snapshotsync.RoSnapshots
|
||||
|
||||
func allSnapshots(cc *params.ChainConfig, db kv.RwDB) *snapshotsync.RoSnapshots {
|
||||
openSnapshotOnce.Do(func() {
|
||||
syncmode, err := ethconfig.SyncModeByChainName(cc.ChainName, syncmodeStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
syncmode := ethconfig.SyncModeByChainName(cc.ChainName, syncmodeStr)
|
||||
snapCfg := ethconfig.NewSnapCfg(syncmode == ethconfig.SnapSync, true, true)
|
||||
if err := db.Update(context.Background(), func(tx kv.RwTx) error { return snap.EnsureNotChanged(tx, snapCfg) }); err != nil {
|
||||
panic(err)
|
||||
|
@ -114,10 +114,7 @@ func CheckChangeSets(genesis *core.Genesis, logger log.Logger, blockNum uint64,
|
||||
|
||||
var blockReader services.FullBlockReader
|
||||
var allSnapshots *snapshotsync.RoSnapshots
|
||||
syncMode, err := ethconfig.SyncModeByChainName(chainConfig.ChainName, syncmodeCli)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
syncMode := ethconfig.SyncModeByChainName(chainConfig.ChainName, syncmodeCli)
|
||||
if syncMode == ethconfig.SnapSync {
|
||||
allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
|
||||
defer allSnapshots.Close()
|
||||
|
@ -224,10 +224,7 @@ func Erigon2(genesis *core.Genesis, chainConfig *params.ChainConfig, logger log.
|
||||
|
||||
var blockReader services.FullBlockReader
|
||||
var allSnapshots *snapshotsync.RoSnapshots
|
||||
syncMode, err := ethconfig.SyncModeByChainName(chainConfig.ChainName, syncmodeCli)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
syncMode := ethconfig.SyncModeByChainName(chainConfig.ChainName, syncmodeCli)
|
||||
if syncMode == ethconfig.SnapSync {
|
||||
allSnapshots = snapshotsync.NewRoSnapshots(ethconfig.NewSnapCfg(true, false, true), path.Join(datadir, "snapshots"))
|
||||
defer allSnapshots.Close()
|
||||
|
@ -180,10 +180,8 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
|
||||
return nil, genesisErr
|
||||
}
|
||||
|
||||
config.Sync.Mode, err = ethconfig.SyncModeByChainName(chainConfig.ChainName, config.Sync.ModeCli)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.Sync.Mode = ethconfig.SyncModeByChainName(chainConfig.ChainName, config.Sync.ModeCli)
|
||||
log.Info("Syncmode", "type", config.Sync.Mode)
|
||||
config.Snapshot.Enabled = config.Sync.Mode == ethconfig.SnapSync
|
||||
|
||||
types.SetHeaderSealFlag(chainConfig.IsHeaderWithSeal())
|
||||
|
@ -18,7 +18,6 @@
|
||||
package ethconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"os/user"
|
||||
@ -37,6 +36,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/ethdb/prune"
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
"github.com/ledgerwatch/erigon/params/networkname"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
)
|
||||
|
||||
// FullNodeGPO contains default gasprice oracle settings for full node.
|
||||
@ -246,19 +246,19 @@ const (
|
||||
SnapSync SyncMode = "snap"
|
||||
)
|
||||
|
||||
func SyncModeByChainName(chain, syncCliFlag string) (SyncMode, error) {
|
||||
func SyncModeByChainName(chain, syncCliFlag string) SyncMode {
|
||||
if syncCliFlag == "full" {
|
||||
return FullSync, nil
|
||||
return FullSync
|
||||
} else if syncCliFlag == "snap" {
|
||||
return SnapSync, nil
|
||||
return SnapSync
|
||||
} else if syncCliFlag != "" {
|
||||
return FullSync, fmt.Errorf("unexpected syncmode: %s, only next options are valid: %s, %s", syncCliFlag, FullSync, SnapSync)
|
||||
log.Warn("Unexpected Syncmode", "got", syncCliFlag, "option_1", FullSync, "option_2 ", SnapSync)
|
||||
}
|
||||
switch chain {
|
||||
case networkname.MainnetChainName, networkname.BSCChainName, networkname.GoerliChainName,
|
||||
networkname.RopstenChainName:
|
||||
return SnapSync, nil
|
||||
return SnapSync
|
||||
default:
|
||||
return FullSync, nil
|
||||
return FullSync
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ func Enabled(tx kv.Getter) (bool, error) {
|
||||
return kv.GetBool(tx, kv.DatabaseInfo, blockSnapshotEnabledKey)
|
||||
}
|
||||
|
||||
// makes sure that erigon is on the same syncmode used previously
|
||||
func EnsureNotChanged(tx kv.GetPut, cfg ethconfig.Snapshot) error {
|
||||
ok, v, err := kv.EnsureNotChangedBool(tx, kv.DatabaseInfo, blockSnapshotEnabledKey, cfg.Enabled)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user