mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 18:42:19 +00:00
nil pointer in admin_nodeInfo #4179
This commit is contained in:
parent
55a4fa75b4
commit
eb614bca88
@ -17,11 +17,12 @@
|
|||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"github.com/ledgerwatch/erigon-lib/kv"
|
"github.com/ledgerwatch/erigon-lib/kv"
|
||||||
"github.com/ledgerwatch/erigon/common"
|
"github.com/ledgerwatch/erigon/common"
|
||||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||||
"github.com/ledgerwatch/erigon/params"
|
"github.com/ledgerwatch/erigon/params"
|
||||||
"math/big"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -59,13 +60,17 @@ type NodeInfo struct {
|
|||||||
|
|
||||||
// ReadNodeInfo retrieves some `eth` protocol metadata about the running host node.
|
// ReadNodeInfo retrieves some `eth` protocol metadata about the running host node.
|
||||||
func ReadNodeInfo(getter kv.Getter, config *params.ChainConfig, genesisHash common.Hash, network uint64) *NodeInfo {
|
func ReadNodeInfo(getter kv.Getter, config *params.ChainConfig, genesisHash common.Hash, network uint64) *NodeInfo {
|
||||||
head := rawdb.ReadCurrentHeader(getter)
|
headHash := rawdb.ReadHeadHeaderHash(getter)
|
||||||
td, _ := rawdb.ReadTd(getter, head.Hash(), head.Number.Uint64())
|
headNumber := rawdb.ReadHeaderNumber(getter, headHash)
|
||||||
|
var td *big.Int
|
||||||
|
if headNumber != nil {
|
||||||
|
td, _ = rawdb.ReadTd(getter, headHash, *headNumber)
|
||||||
|
}
|
||||||
return &NodeInfo{
|
return &NodeInfo{
|
||||||
Network: network,
|
Network: network,
|
||||||
Difficulty: td,
|
Difficulty: td,
|
||||||
Genesis: genesisHash,
|
Genesis: genesisHash,
|
||||||
Config: config,
|
Config: config,
|
||||||
Head: head.Hash(),
|
Head: headHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user