mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
revert & fix
This commit is contained in:
parent
9645d9b1d6
commit
3890069976
1 changed files with 16 additions and 1 deletions
|
|
@ -175,7 +175,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
|
|
||||||
// Here we determine genesis hash and active ChainConfig.
|
// Here we determine genesis hash and active ChainConfig.
|
||||||
// We need these to figure out the consensus parameters and to set up history pruning.
|
// We need these to figure out the consensus parameters and to set up history pruning.
|
||||||
chainConfig, _, err := core.LoadChainConfig(chainDb, config.Genesis)
|
chainConfig, ghash, err := core.LoadChainConfig(chainDb, config.Genesis)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +189,21 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
networkID = chainConfig.ChainID.Uint64()
|
networkID = chainConfig.ChainID.Uint64()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch to full sync if we're in snap sync and genesis block is in the future.
|
||||||
|
if config.SyncMode == ethconfig.SnapSync {
|
||||||
|
genesisTime := uint64(0)
|
||||||
|
now := uint64(time.Now().Unix())
|
||||||
|
if config.Genesis != nil {
|
||||||
|
genesisTime = config.Genesis.Timestamp
|
||||||
|
} else if genesis := rawdb.ReadBlock(chainDb, ghash, 0); genesis != nil {
|
||||||
|
genesisTime = genesis.Time()
|
||||||
|
}
|
||||||
|
if genesisTime > uint64(now) {
|
||||||
|
log.Warn("Genesis block is in the future, switching from snap sync to full sync")
|
||||||
|
config.SyncMode = ethconfig.FullSync
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Assemble the Ethereum object.
|
// Assemble the Ethereum object.
|
||||||
eth := &Ethereum{
|
eth := &Ethereum{
|
||||||
config: config,
|
config: config,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue