mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
eth: improve getting chainID with existence check and hexutil
This commit is contained in:
parent
ee555bcc9d
commit
acc65d681d
1 changed files with 6 additions and 2 deletions
|
|
@ -72,8 +72,12 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
|
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
|
||||||
func (api *PublicEthereumAPI) ChainId() *big.Int {
|
func (api *PublicEthereumAPI) ChainId() hexutil.Uint {
|
||||||
return api.e.chainConfig.ChainId
|
chainID := new(big.Int)
|
||||||
|
if config := api.e.chainConfig; config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
|
||||||
|
chainID = config.ChainId
|
||||||
|
}
|
||||||
|
return hexutil.Uint(chainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicMinerAPI provides an API to control the miner.
|
// PublicMinerAPI provides an API to control the miner.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue