mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 09:20:44 +00:00
core/rawdb: refactor func WriteChainConfig (#1805)
This commit is contained in:
parent
e3efe5e0bb
commit
6450d5bbb9
1 changed files with 5 additions and 7 deletions
|
|
@ -69,19 +69,17 @@ func ReadChainConfig(db ethdb.KeyValueReader, hash common.Hash) (*params.ChainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteChainConfig writes the chain config settings to the database.
|
// WriteChainConfig writes the chain config settings to the database.
|
||||||
func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.ChainConfig) error {
|
func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.ChainConfig) {
|
||||||
// short circuit and ignore if nil config. GetChainConfig
|
|
||||||
// will return a default.
|
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(cfg)
|
data, err := json.Marshal(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to JSON encode chain config", "err", err)
|
log.Crit("Failed to JSON encode chain config", "err", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
return db.Put(configKey(hash), data)
|
if err := db.Put(configKey(hash), data); err != nil {
|
||||||
|
log.Crit("Failed to store chain config", "err", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadGenesisStateSpec retrieves the genesis state specification based on the
|
// ReadGenesisStateSpec retrieves the genesis state specification based on the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue