Skip to content

Commit 0045ce4

Browse files
committed
Future blocks not allowed
1 parent 465b0a7 commit 0045ce4

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

‎core/block_processor.go‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"math/big"
77
"sync"
8+
"time"
89

910
"github.com/ethereum/go-ethereum/core/types"
1011
"github.com/ethereum/go-ethereum/crypto"
@@ -251,15 +252,12 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error {
251252
return ValidationError("Block timestamp less then prev block %v (%v - %v)", diff, block.Header().Time, sm.bc.CurrentBlock().Header().Time)
252253
}
253254

254-
/* XXX
255-
// New blocks must be within the 15 minute range of the last block.
256-
if diff > int64(15*time.Minute) {
257-
return ValidationError("Block is too far in the future of last block (> 15 minutes)")
255+
if block.Time() > time.Now().Unix() {
256+
return fmt.Errorf("block time is in the future")
258257
}
259-
*/
260258

261259
// Verify the nonce of the block. Return an error if it's not valid
262-
if !sm.Pow.Verify(block /*block.HashNoNonce(), block.Difficulty, block.Nonce*/) {
260+
if !sm.Pow.Verify(block) {
263261
return ValidationError("Block's nonce is invalid (= %v)", ethutil.Bytes2Hex(block.Header().Nonce))
264262
}
265263

@@ -287,21 +285,6 @@ func (sm *BlockProcessor) AccumelateRewards(statedb *state.StateDB, block, paren
287285
return UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4]))
288286
}
289287

290-
/*
291-
uncleParent := sm.bc.GetBlock(uncle.ParentHash)
292-
if uncleParent == nil {
293-
return UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4]))
294-
}
295-
296-
if uncleParent.Number().Cmp(new(big.Int).Sub(parent.Number(), big.NewInt(6))) < 0 {
297-
return UncleError("Uncle too old")
298-
}
299-
300-
if knownUncles.Has(string(uncle.Hash())) {
301-
return UncleError("Uncle in chain")
302-
}
303-
*/
304-
305288
r := new(big.Int)
306289
r.Mul(BlockReward, big.NewInt(15)).Div(r, big.NewInt(16))
307290

0 commit comments

Comments
 (0)