eth: improve getting chainID with existence check and hexutil

This commit is contained in:
ia 2017-09-06 11:08:06 -05:00 committed by hackyminer
parent 51dd117a34
commit df4f7c867e
No known key found for this signature in database
GPG key ID: 46D453DDCA4B766F

View file

@ -68,8 +68,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.