diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-02 05:37:17 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-02 05:37:17 +0800 |
commit | 219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be (patch) | |
tree | a27922e01862131c998db6a93fd42ddb7a8247e9 /core/block_processor.go | |
parent | ab5c007376e36cde14cdb060ad4786f016c713d4 (diff) | |
parent | c26c8d3a44cdd45994b6d99777d620565bab8f9c (diff) | |
download | go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar.gz go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar.bz2 go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar.lz go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar.xz go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.tar.zst go-tangerine-219d94c1ddcb1e1e8a3fbfcfdcb545e6271dd5be.zip |
Merge pull request #623 from Gustav-Simonsson/read_protocol_values_from_common_params
Read most protocol params from common/params.json
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index ec68dc6c9..0591fd26e 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -11,6 +11,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/pow" "github.com/ethereum/go-ethereum/rlp" "gopkg.in/fatih/set.v0" @@ -254,7 +255,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big // an uncle or anything that isn't on the current block chain. // Validation validates easy over difficult (dagger takes longer time = difficult) func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error { - if len(block.Extra) > 1024 { + if big.NewInt(int64(len(block.Extra))).Cmp(params.MaximumExtraDataSize) == 1 { return fmt.Errorf("Block extra data too long (%d)", len(block.Extra)) } @@ -263,13 +264,11 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd) } - // TODO: use use minGasLimit and gasLimitBoundDivisor from - // https://github.com/ethereum/common/blob/master/params.json - // block.gasLimit - parent.gasLimit <= parent.gasLimit / 1024 + // block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor a := new(big.Int).Sub(block.GasLimit, parent.GasLimit) a.Abs(a) - b := new(big.Int).Div(parent.GasLimit, big.NewInt(1024)) - if !(a.Cmp(b) < 0) { + b := new(big.Int).Div(parent.GasLimit, params.GasLimitBoundDivisor) + if !(a.Cmp(b) < 0) || (block.GasLimit.Cmp(params.MinGasLimit) == -1) { return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) } |