mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +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.
|
||||
func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.ChainConfig) error {
|
||||
// short circuit and ignore if nil config. GetChainConfig
|
||||
// will return a default.
|
||||
func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.ChainConfig) {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
data, err := json.Marshal(cfg)
|
||||
if err != nil {
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue