aboutsummaryrefslogtreecommitdiffstats
path: root/params/config.go
diff options
context:
space:
mode:
authorkiel barry <kiel.j.barry@gmail.com>2018-06-05 18:31:34 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-06-05 18:31:34 +0800
commitcbfb40b0aab093e1b612f3b16834894b2cc67882 (patch)
tree19cbd1397343459aabf211857fcc5df26f4cee6c /params/config.go
parent4cf2b4110e9942bdcba1b9b1d82b3ca8ff552f64 (diff)
downloaddexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar.gz
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar.bz2
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar.lz
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar.xz
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.tar.zst
dexon-cbfb40b0aab093e1b612f3b16834894b2cc67882.zip
params: fix golint warnings (#16853)
params: fix golint warnings
Diffstat (limited to 'params/config.go')
-rw-r--r--params/config.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/params/config.go b/params/config.go
index dc02c7ca3..6e6a5cb8b 100644
--- a/params/config.go
+++ b/params/config.go
@@ -23,15 +23,16 @@ import (
"github.com/ethereum/go-ethereum/common"
)
+// Genesis hashes to enforce below configs on.
var (
- MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
- TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
+ MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
+ TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
)
var (
// MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &ChainConfig{
- ChainId: big.NewInt(1),
+ ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: true,
@@ -46,7 +47,7 @@ var (
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
TestnetChainConfig = &ChainConfig{
- ChainId: big.NewInt(3),
+ ChainID: big.NewInt(3),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
@@ -61,7 +62,7 @@ var (
// RinkebyChainConfig contains the chain parameters to run a node on the Rinkeby test network.
RinkebyChainConfig = &ChainConfig{
- ChainId: big.NewInt(4),
+ ChainID: big.NewInt(4),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: nil,
DAOForkSupport: true,
@@ -101,7 +102,7 @@ var (
// that any network, identified by its genesis block, can have its own
// set of configuration options.
type ChainConfig struct {
- ChainId *big.Int `json:"chainId"` // Chain id identifies the current chain and is used for replay protection
+ ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
@@ -154,7 +155,7 @@ func (c *ChainConfig) String() string {
engine = "unknown"
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}",
- c.ChainId,
+ c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
c.DAOForkSupport,
@@ -172,27 +173,32 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool {
return isForked(c.HomesteadBlock, num)
}
-// IsDAO returns whether num is either equal to the DAO fork block or greater.
+// IsDAOFork returns whether num is either equal to the DAO fork block or greater.
func (c *ChainConfig) IsDAOFork(num *big.Int) bool {
return isForked(c.DAOForkBlock, num)
}
+// IsEIP150 returns whether num is either equal to the EIP150 fork block or greater.
func (c *ChainConfig) IsEIP150(num *big.Int) bool {
return isForked(c.EIP150Block, num)
}
+// IsEIP155 returns whether num is either equal to the EIP155 fork block or greater.
func (c *ChainConfig) IsEIP155(num *big.Int) bool {
return isForked(c.EIP155Block, num)
}
+// IsEIP158 returns whether num is either equal to the EIP158 fork block or greater.
func (c *ChainConfig) IsEIP158(num *big.Int) bool {
return isForked(c.EIP158Block, num)
}
+// IsByzantium returns whether num is either equal to the Byzantium fork block or greater.
func (c *ChainConfig) IsByzantium(num *big.Int) bool {
return isForked(c.ByzantiumBlock, num)
}
+// IsConstantinople returns whether num is either equal to the Constantinople fork block or greater.
func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
return isForked(c.ConstantinopleBlock, num)
}
@@ -251,7 +257,7 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible(c.EIP158Block, newcfg.EIP158Block, head) {
return newCompatError("EIP158 fork block", c.EIP158Block, newcfg.EIP158Block)
}
- if c.IsEIP158(head) && !configNumEqual(c.ChainId, newcfg.ChainId) {
+ if c.IsEIP158(head) && !configNumEqual(c.ChainID, newcfg.ChainID) {
return newCompatError("EIP158 chain ID", c.EIP158Block, newcfg.EIP158Block)
}
if isForkIncompatible(c.ByzantiumBlock, newcfg.ByzantiumBlock, head) {
@@ -324,15 +330,16 @@ func (err *ConfigCompatError) Error() string {
// Rules is a one time interface meaning that it shouldn't be used in between transition
// phases.
type Rules struct {
- ChainId *big.Int
+ ChainID *big.Int
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
IsByzantium bool
}
+// Rules ensures c's ChainID is not nil.
func (c *ChainConfig) Rules(num *big.Int) Rules {
- chainId := c.ChainId
- if chainId == nil {
- chainId = new(big.Int)
+ chainID := c.ChainID
+ if chainID == nil {
+ chainID = new(big.Int)
}
- return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)}
+ return Rules{ChainID: new(big.Int).Set(chainID), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)}
}