aboutsummaryrefslogtreecommitdiffstats
path: root/params
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-11-02 20:44:13 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-11-13 21:55:30 +0800
commit4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188 (patch)
tree5c55a3088c944ddf517aa4d7c85c5dc7f02d00e4 /params
parent5cd86443ee071b5e3abe4995c777ce467c29f2c5 (diff)
downloaddexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.gz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.bz2
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.lz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.xz
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.tar.zst
dexon-4dca5d4db7fc2c1fac5a2e24dcc99b15573f0188.zip
core/types, params: EIP#155
Diffstat (limited to 'params')
-rw-r--r--params/config.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/params/config.go b/params/config.go
index 684e4dc42..d63236ef8 100644
--- a/params/config.go
+++ b/params/config.go
@@ -28,18 +28,24 @@ import (
// 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
+
HomesteadBlock *big.Int `json:"homesteadBlock"` // Homestead switch block (nil = no fork, 0 = already homestead)
DAOForkBlock *big.Int `json:"daoForkBlock"` // TheDAO hard-fork switch block (nil = no fork)
DAOForkSupport bool `json:"daoForkSupport"` // Whether the nodes supports or opposes the DAO hard-fork
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
- EIP150Block *big.Int `json:"EIP150Block"` // EIP150 HF block (nil = no fork)
- EIP150Hash common.Hash `json:"EIP150Hash"` // EIP150 HF hash (fast sync aid)
+ EIP150Block *big.Int `json:"eip150Block"` // EIP150 HF block (nil = no fork)
+ EIP150Hash common.Hash `json:"eip150Hash"` // EIP150 HF hash (fast sync aid)
- EIP158Block *big.Int `json:"EIP158Block"` // EIP158 HF block
+ EIP155Block *big.Int `json:"eip155Block"` // EIP155 HF block
+ EIP158Block *big.Int `json:"eip158Block"` // EIP158 HF block
}
-var TestChainConfig = &ChainConfig{new(big.Int), new(big.Int), true, new(big.Int), common.Hash{}, new(big.Int)}
+var (
+ TestChainConfig = &ChainConfig{big.NewInt(1), new(big.Int), new(big.Int), true, new(big.Int), common.Hash{}, new(big.Int), new(big.Int)}
+ TestRules = TestChainConfig.Rules(new(big.Int))
+)
// IsHomestead returns whether num is either equal to the homestead block or greater.
func (c *ChainConfig) IsHomestead(num *big.Int) bool {
@@ -75,6 +81,14 @@ func (c *ChainConfig) IsEIP150(num *big.Int) bool {
}
+func (c *ChainConfig) IsEIP155(num *big.Int) bool {
+ if c.EIP155Block == nil || num == nil {
+ return false
+ }
+ return num.Cmp(c.EIP155Block) >= 0
+
+}
+
func (c *ChainConfig) IsEIP158(num *big.Int) bool {
if c.EIP158Block == nil || num == nil {
return false
@@ -82,3 +96,17 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
return num.Cmp(c.EIP158Block) >= 0
}
+
+// Rules wraps ChainConfig and is merely syntatic sugar or can be used for functions
+// that do not have or require information about the block.
+//
+// Rules is a one time interface meaning that it shouldn't be used in between transition
+// phases.
+type Rules struct {
+ ChainId *big.Int
+ IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
+}
+
+func (c *ChainConfig) Rules(num *big.Int) Rules {
+ return Rules{ChainId: new(big.Int).Set(c.ChainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num)}
+}