diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-09 01:09:36 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-09 01:09:36 +0800 |
commit | 5a0bae1dae831818740a2f20ca308c4176f5201d (patch) | |
tree | 33fc52996530ebb7c467880975554a91d94471c6 /ethchain/state_manager.go | |
parent | e8fb965ccbb65807c1f462e8f2ee82508a822b58 (diff) | |
download | go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.gz go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.bz2 go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.lz go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.xz go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.zst go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.zip |
Auto update state changes notifications
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 76b02f9ab..9ab378b67 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -47,7 +47,9 @@ type StateManager struct { // the main states. transState *State // Manifest for keeping changes regarding state objects. See `notify` - manifest *Manifest + // XXX Should we move the manifest to the State object. Benefit: + // * All states can keep their own local changes + //manifest *Manifest } func NewStateManager(ethereum EthManager) *StateManager { @@ -57,7 +59,7 @@ func NewStateManager(ethereum EthManager) *StateManager { Pow: &EasyPow{}, Ethereum: ethereum, bc: ethereum.BlockChain(), - manifest: NewManifest(), + //manifest: NewManifest(), } sm.procState = ethereum.BlockChain().CurrentBlock.State() sm.transState = sm.procState.Copy() @@ -190,7 +192,7 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error { sm.notifyChanges() - sm.manifest.Reset() + sm.procState.manifest.Reset() } } else { fmt.Println("total diff failed") @@ -315,18 +317,15 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans // Update the account (refunds) sm.procState.UpdateStateObject(account) - sm.manifest.AddObjectChange(account) - sm.procState.UpdateStateObject(object) - sm.manifest.AddObjectChange(object) } func (sm *StateManager) notifyChanges() { - for addr, stateObject := range sm.manifest.objectChanges { + for addr, stateObject := range sm.procState.manifest.objectChanges { sm.Ethereum.Reactor().Post("object:"+addr, stateObject) } - for stateObjectAddr, mappedObjects := range sm.manifest.storageChanges { + for stateObjectAddr, mappedObjects := range sm.procState.manifest.storageChanges { for addr, value := range mappedObjects { sm.Ethereum.Reactor().Post("storage:"+stateObjectAddr+":"+addr, &StorageState{[]byte(stateObjectAddr), []byte(addr), value}) } |