aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-10 23:00:06 +0800
committerobscuren <geffobscura@gmail.com>2014-10-10 23:00:06 +0800
commite02c0fa8088943bc995d290e58a7226f4a0ece91 (patch)
tree1bc2ac212b46d3892dd2720304efb2ab97e43528 /ethchain/state_manager.go
parent9b494c68698cbcaa4d8d6e0f2b964d29db815da5 (diff)
downloaddexon-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.gz
dexon-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.zst
dexon-e02c0fa8088943bc995d290e58a7226f4a0ece91.zip
Added generic big to 256 method. Implemented new iterator
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go8
1 files changed, 5 insertions, 3 deletions
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)