diff options
author | Maran <maran.hidskes@gmail.com> | 2014-03-10 18:53:02 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-03-10 18:53:02 +0800 |
commit | d5efeab8f92509dec3cafcafb36e1856bb084f12 (patch) | |
tree | 1d455afb8824391da15b2f537f17f87fb1678998 /ethchain/state_manager.go | |
parent | be543a6d178063a60d404a373ced296ed6d4744c (diff) | |
download | go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar.gz go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar.bz2 go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar.lz go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar.xz go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.tar.zst go-tangerine-d5efeab8f92509dec3cafcafb36e1856bb084f12.zip |
Initial smart-miner stuff
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 15 |
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") } |