2020-10-03 08:07:49 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2020-10-16 12:15:10 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
2020-10-03 08:07:49 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/core/rawdb"
|
2020-11-22 21:25:26 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2020-10-03 08:07:49 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/params"
|
|
|
|
)
|
|
|
|
|
2020-11-22 21:25:26 +00:00
|
|
|
func getChainConfig(db ethdb.Database) (*params.ChainConfig, error) {
|
2020-10-24 06:57:09 +00:00
|
|
|
cfg, _, err := getChainConfigWithGenesis(db)
|
|
|
|
return cfg, err
|
2020-10-16 12:15:10 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 21:25:26 +00:00
|
|
|
func getChainConfigWithGenesis(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
|
2020-10-24 06:57:09 +00:00
|
|
|
genesis, err := rawdb.ReadBlockByNumber(db, 0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, common.Hash{}, err
|
|
|
|
}
|
|
|
|
genesisHash := genesis.Hash()
|
|
|
|
cc, err := rawdb.ReadChainConfig(db, genesisHash)
|
|
|
|
if err != nil {
|
|
|
|
return nil, common.Hash{}, err
|
|
|
|
}
|
|
|
|
return cc, genesisHash, nil
|
2020-10-03 08:07:49 +00:00
|
|
|
}
|