From e02c0fa8088943bc995d290e58a7226f4a0ece91 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 10 Oct 2014 17:00:06 +0200 Subject: Added generic big to 256 method. Implemented new iterator --- ethchain/state_manager.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ethchain/state_manager.go') diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 93fd1ec58..589b99ac2 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -346,9 +346,6 @@ func (sm *StateManager) CalculateTD(block *Block) bool { // an uncle or anything that isn't on the current block chain. // Validation validates easy over difficult (dagger takes longer time = difficult) func (sm *StateManager) ValidateBlock(block *Block) error { - // TODO - // 2. Check if the difficulty is correct - // Check each uncle's previous hash. In order for it to be valid // is if it has the same block hash as the current parent := sm.bc.GetBlock(block.PrevHash) @@ -360,6 +357,11 @@ func (sm *StateManager) ValidateBlock(block *Block) error { } */ + expd := CalcDifficulty(block, parent) + if expd.Cmp(block.Difficulty) < 0 { + return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd) + } + diff := block.Time - parent.Time if diff < 0 { return ValidationError("Block timestamp less then prev block %v (%v - %v)", diff, block.Time, sm.bc.CurrentBlock.Time) -- cgit v1.2.3