aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 27eaa5e60..8c442cf44 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -132,8 +132,19 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
}
}
+func (sm *StateManager) Process(block *Block, dontReact bool) error {
+ if !sm.bc.HasBlock(block.PrevHash) {
+ return ParentError(block.PrevHash)
+ }
+
+ parent := sm.bc.GetBlock(block.PrevHash)
+
+ return sm.ProcessBlock(parent.State(), parent, block, dontReact)
+
+}
+
// Block processing and validating with a given (temporarily) state
-func (sm *StateManager) ProcessBlock(state *State, block *Block, dontReact bool) error {
+func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontReact bool) error {
// Processing a blocks may never happen simultaneously
sm.mutex.Lock()
defer sm.mutex.Unlock()
@@ -186,7 +197,7 @@ func (sm *StateManager) ProcessBlock(state *State, block *Block, dontReact bool)
sm.bc.Add(block)
sm.notifyChanges(state)
- ethutil.Config.Log.Infof("[STATE] Added block #%d (%x)\n", block.BlockInfo().Number, block.Hash())
+ ethutil.Config.Log.Infof("[STATE] Added block #%d (%x)\n", block.Number, block.Hash())
if dontReact == false {
sm.Ethereum.Reactor().Post("newBlock", block)