eth: improve getting chainID with existence check and hexutil

This commit is contained in:
ia 2017-09-06 11:08:06 -05:00
parent ee555bcc9d
commit acc65d681d
No known key found for this signature in database
GPG key ID: F36487257419D94C

View file

@ -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.
func (api *PublicEthereumAPI) ChainId() *big.Int {
return api.e.chainConfig.ChainId
func (api *PublicEthereumAPI) ChainId() hexutil.Uint {
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.