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, 15 insertions, 0 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 7085146df..2652f3f29 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -19,6 +19,7 @@ type EthManager interface {
BlockChain() *BlockChain
TxPool() *TxPool
Broadcast(msgType ethwire.MsgType, data []interface{})
+ Reactor() *ethutil.ReactorEngine
}
// TODO rename to state manager
@@ -50,6 +51,9 @@ type StateManager struct {
// Comparative state it used for comparing and validating end
// results
compState *State
+
+ // Mining state, solely used for mining
+ miningState *State
}
func NewStateManager(ethereum EthManager) *StateManager {
@@ -69,6 +73,10 @@ func (sm *StateManager) ProcState() *State {
return sm.procState
}
+func (sm *StateManager) MiningState() *State {
+ return sm.miningState
+}
+
// Watches any given address and puts it in the address state store
func (sm *StateManager) WatchAddr(addr []byte) *AccountState {
//FIXME account := sm.procState.GetAccount(addr)
@@ -97,6 +105,8 @@ func (sm *StateManager) MakeContract(tx *Transaction) {
sm.procState.states[string(tx.Hash()[12:])] = contract.state
}
}
+func (sm *StateManager) ApplyTransaction(block *Block, tx *Transaction) {
+}
func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
// Process each transaction/contract
@@ -126,6 +136,10 @@ func (sm *StateManager) Prepare(processer *State, comparative *State) {
sm.procState = processer
}
+func (sm *StateManager) PrepareMiningState() {
+ sm.miningState = sm.BlockChain().CurrentBlock.State()
+}
+
// Default prepare function
func (sm *StateManager) PrepareDefault(block *Block) {
sm.Prepare(sm.BlockChain().CurrentBlock.State(), block.State())
@@ -193,6 +207,7 @@ func (sm *StateManager) ProcessBlock(block *Block) error {
}
ethutil.Config.Log.Infof("[smGR] Added block #%d (%x)\n", block.BlockInfo().Number, block.Hash())
+ sm.Ethereum.Reactor().Post("newBlock", block)
} else {
fmt.Println("total diff failed")
}