aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-09 00:41:45 +0800
committerobscuren <geffobscura@gmail.com>2014-05-09 00:41:45 +0800
commite8fb965ccbb65807c1f462e8f2ee82508a822b58 (patch)
tree862ac20a37a1ae00989258c7234be5bbf3bb833e /ethchain
parentd709815106824a3469b5f4152fd32705d7d142d4 (diff)
downloaddexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar.gz
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar.bz2
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar.lz
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar.xz
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.tar.zst
dexon-e8fb965ccbb65807c1f462e8f2ee82508a822b58.zip
Cleaned up
Removed the unneeded address watch mechanism. State manager's transient state should now take care of this.
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/state_manager.go33
-rw-r--r--ethchain/state_object.go29
2 files changed, 11 insertions, 51 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index fb5753ab3..76b02f9ab 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -25,24 +25,16 @@ type EthManager interface {
type StateManager struct {
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
-
// Canonical block chain
bc *BlockChain
- // States for addresses. You can watch any address
- // at any given time
- stateObjectCache *StateObjectCache
-
// Stack for processing contracts
stack *Stack
// non-persistent key/value memory storage
mem map[string]*big.Int
-
+ // Proof of work used for validating
Pow PoW
-
+ // The ethereum manager interface
Ethereum EthManager
-
- SecondaryBlockProcessor BlockProcessor
-
// The managed states
// Processor state. Anything processed will be applied to this
// state
@@ -54,19 +46,18 @@ type StateManager struct {
// it could be used for setting account nonces without effecting
// the main states.
transState *State
-
+ // Manifest for keeping changes regarding state objects. See `notify`
manifest *Manifest
}
func NewStateManager(ethereum EthManager) *StateManager {
sm := &StateManager{
- stack: NewStack(),
- mem: make(map[string]*big.Int),
- Pow: &EasyPow{},
- Ethereum: ethereum,
- stateObjectCache: NewStateObjectCache(),
- bc: ethereum.BlockChain(),
- manifest: NewManifest(),
+ stack: NewStack(),
+ mem: make(map[string]*big.Int),
+ Pow: &EasyPow{},
+ Ethereum: ethereum,
+ bc: ethereum.BlockChain(),
+ manifest: NewManifest(),
}
sm.procState = ethereum.BlockChain().CurrentBlock.State()
sm.transState = sm.procState.Copy()
@@ -193,12 +184,6 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
// Add the block to the chain
sm.bc.Add(block)
- // If there's a block processor present, pass in the block for further
- // processing
- if sm.SecondaryBlockProcessor != nil {
- sm.SecondaryBlockProcessor.ProcessBlock(block)
- }
-
ethutil.Config.Log.Infof("[STATE] Added block #%d (%x)\n", block.BlockInfo().Number, block.Hash())
if dontReact == false {
sm.Ethereum.Reactor().Post("newBlock", block)
diff --git a/ethchain/state_object.go b/ethchain/state_object.go
index 617646077..b38ee4f5c 100644
--- a/ethchain/state_object.go
+++ b/ethchain/state_object.go
@@ -160,33 +160,8 @@ func (c *StateObject) RlpDecode(data []byte) {
c.script = decoder.Get(3).Bytes()
}
-// The cached state and state object cache are helpers which will give you somewhat
-// control over the nonce. When creating new transactions you're interested in the 'next'
-// nonce rather than the current nonce. This to avoid creating invalid-nonce transactions.
-type StateObjectCache struct {
- cachedObjects map[string]*CachedStateObject
-}
-
-func NewStateObjectCache() *StateObjectCache {
- return &StateObjectCache{cachedObjects: make(map[string]*CachedStateObject)}
-}
-
-func (s *StateObjectCache) Add(addr []byte, object *StateObject) *CachedStateObject {
- state := &CachedStateObject{Nonce: object.Nonce, Object: object}
- s.cachedObjects[string(addr)] = state
-
- return state
-}
-
-func (s *StateObjectCache) Get(addr []byte) *CachedStateObject {
- return s.cachedObjects[string(addr)]
-}
-
-type CachedStateObject struct {
- Nonce uint64
- Object *StateObject
-}
-
+// Storage change object. Used by the manifest for notifying changes to
+// the sub channels.
type StorageState struct {
StateAddress []byte
Address []byte