Cleaned up
Removed the unneeded address watch mechanism. State manager's transient state should now take care of this.
This commit is contained in:
parent
d709815106
commit
e8fb965ccb
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user