forked from cerc-io/plugeth
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 {
|
type StateManager struct {
|
||||||
// Mutex for locking the block processor. Blocks can only be handled one at a time
|
// Mutex for locking the block processor. Blocks can only be handled one at a time
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
|
|
||||||
// Canonical block chain
|
// Canonical block chain
|
||||||
bc *BlockChain
|
bc *BlockChain
|
||||||
// States for addresses. You can watch any address
|
|
||||||
// at any given time
|
|
||||||
stateObjectCache *StateObjectCache
|
|
||||||
|
|
||||||
// Stack for processing contracts
|
// Stack for processing contracts
|
||||||
stack *Stack
|
stack *Stack
|
||||||
// non-persistent key/value memory storage
|
// non-persistent key/value memory storage
|
||||||
mem map[string]*big.Int
|
mem map[string]*big.Int
|
||||||
|
// Proof of work used for validating
|
||||||
Pow PoW
|
Pow PoW
|
||||||
|
// The ethereum manager interface
|
||||||
Ethereum EthManager
|
Ethereum EthManager
|
||||||
|
|
||||||
SecondaryBlockProcessor BlockProcessor
|
|
||||||
|
|
||||||
// The managed states
|
// The managed states
|
||||||
// Processor state. Anything processed will be applied to this
|
// Processor state. Anything processed will be applied to this
|
||||||
// state
|
// state
|
||||||
@ -54,7 +46,7 @@ type StateManager struct {
|
|||||||
// it could be used for setting account nonces without effecting
|
// it could be used for setting account nonces without effecting
|
||||||
// the main states.
|
// the main states.
|
||||||
transState *State
|
transState *State
|
||||||
|
// Manifest for keeping changes regarding state objects. See `notify`
|
||||||
manifest *Manifest
|
manifest *Manifest
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +56,6 @@ func NewStateManager(ethereum EthManager) *StateManager {
|
|||||||
mem: make(map[string]*big.Int),
|
mem: make(map[string]*big.Int),
|
||||||
Pow: &EasyPow{},
|
Pow: &EasyPow{},
|
||||||
Ethereum: ethereum,
|
Ethereum: ethereum,
|
||||||
stateObjectCache: NewStateObjectCache(),
|
|
||||||
bc: ethereum.BlockChain(),
|
bc: ethereum.BlockChain(),
|
||||||
manifest: NewManifest(),
|
manifest: NewManifest(),
|
||||||
}
|
}
|
||||||
@ -193,12 +184,6 @@ func (sm *StateManager) ProcessBlock(block *Block, dontReact bool) error {
|
|||||||
// Add the block to the chain
|
// Add the block to the chain
|
||||||
sm.bc.Add(block)
|
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())
|
ethutil.Config.Log.Infof("[STATE] Added block #%d (%x)\n", block.BlockInfo().Number, block.Hash())
|
||||||
if dontReact == false {
|
if dontReact == false {
|
||||||
sm.Ethereum.Reactor().Post("newBlock", block)
|
sm.Ethereum.Reactor().Post("newBlock", block)
|
||||||
|
@ -160,33 +160,8 @@ func (c *StateObject) RlpDecode(data []byte) {
|
|||||||
c.script = decoder.Get(3).Bytes()
|
c.script = decoder.Get(3).Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// The cached state and state object cache are helpers which will give you somewhat
|
// Storage change object. Used by the manifest for notifying changes to
|
||||||
// control over the nonce. When creating new transactions you're interested in the 'next'
|
// the sub channels.
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
|
||||||
type StorageState struct {
|
type StorageState struct {
|
||||||
StateAddress []byte
|
StateAddress []byte
|
||||||
Address []byte
|
Address []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user