diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-06-30 15:13:16 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-06-30 16:52:11 +0800 |
commit | 4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d (patch) | |
tree | 4bb5055690cae276a5480572b463cd06fa219f23 /core/block_processor.go | |
parent | be935bff84d54cd7a7f4074e2326d62f664ba4e3 (diff) | |
download | go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar.gz go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar.bz2 go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar.lz go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar.xz go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.tar.zst go-tangerine-4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d.zip |
Use uint64 for block header timestamp
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 22d4c7c27..9b77d10eb 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -362,6 +362,13 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check return fmt.Errorf("Block extra data too long (%d)", len(block.Extra)) } + if block.Time > uint64(time.Now().Unix()) { + return BlockFutureErr + } + if block.Time <= parent.Time() { + return BlockEqualTSErr + } + expd := CalcDifficulty(int64(block.Time), int64(parent.Time()), parent.Difficulty()) if expd.Cmp(block.Difficulty) != 0 { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd) @@ -377,20 +384,12 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) } - if int64(block.Time) > time.Now().Unix() { - return BlockFutureErr - } - num := parent.Number() num.Sub(block.Number, num) if num.Cmp(big.NewInt(1)) != 0 { return BlockNumberErr } - if block.Time <= uint64(parent.Time()) { - return BlockEqualTSErr //ValidationError("Block timestamp equal or less than previous block (%v - %v)", block.Time, parent.Time) - } - if checkPow { // Verify the nonce of the block. Return an error if it's not valid if !pow.Verify(types.NewBlockWithHeader(block)) { |