diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-02 11:17:15 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-02 12:22:32 +0800 |
commit | c26c8d3a44cdd45994b6d99777d620565bab8f9c (patch) | |
tree | 6ab5a74981e9fb9f869f1ef884a375163b898113 /core/chain_manager.go | |
parent | 516ec28544e0f9c76e18d82742d3ae58cfb59cc1 (diff) | |
download | go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.gz go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.zst go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.zip |
Read most protocol params from common/params.json
* Add params package with exported variables generated from
github.com/ethereum/common/blob/master/params.json
* Use params package variables in applicable places
* Add check for minimum gas limit in validation of block's gas limit
* Remove common/params.json from go-ethereum to avoid
outdated version of it
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r-- | core/chain_manager.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go index f0d3fd4cf..d97a94b06 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" ) @@ -32,18 +33,15 @@ type StateQuery interface { func CalcDifficulty(block, parent *types.Header) *big.Int { diff := new(big.Int) - diffBoundDiv := big.NewInt(2048) - min := big.NewInt(131072) - - adjust := new(big.Int).Div(parent.Difficulty, diffBoundDiv) - if (block.Time - parent.Time) < 8 { + adjust := new(big.Int).Div(parent.Difficulty, params.DifficultyBoundDivisor) + if big.NewInt(int64(block.Time)-int64(parent.Time)).Cmp(params.DurationLimit) < 0 { diff.Add(parent.Difficulty, adjust) } else { diff.Sub(parent.Difficulty, adjust) } - if diff.Cmp(min) < 0 { - return min + if diff.Cmp(params.MinimumDifficulty) < 0 { + return params.MinimumDifficulty } return diff @@ -76,7 +74,7 @@ func CalcGasLimit(parent, block *types.Block) *big.Int { result := new(big.Int).Add(previous, curInt) result.Div(result, big.NewInt(1024)) - return common.BigMax(GenesisGasLimit, result) + return common.BigMax(params.GenesisGasLimit, result) } type ChainManager struct { |