erigon-pulse/cmd/hack/tool/tool.go
2022-09-08 14:02:50 +07:00

29 lines
522 B
Go

package tool
import (
"strconv"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/params"
)
func Check(e error) {
if e != nil {
panic(e)
}
}
func ParseFloat64(str string) float64 {
v, _ := strconv.ParseFloat(str, 64)
return v
}
func ChainConfig(tx kv.Tx) *params.ChainConfig {
genesisBlock, err := rawdb.ReadBlockByNumber(tx, 0)
Check(err)
chainConfig, err := rawdb.ReadChainConfig(tx, genesisBlock.Hash())
Check(err)
return chainConfig
}