diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-21 19:04:40 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-21 19:04:40 +0800 |
commit | 86cf69648efc5029abffbf39f1be7308acb1531e (patch) | |
tree | 4999dcb67888e4dcbe56ec5a5df844e1169e61e1 /ethchain | |
parent | 0e9c8568fd689fdee0cce2584ad96ecce60c60d7 (diff) | |
download | go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.gz go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.bz2 go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.lz go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.xz go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.zst go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.zip |
Improved miner so it won't include invalid transactions
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/state_manager.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 9fe485b7a..8b56d65bb 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -104,7 +104,7 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra } } -func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transaction) { +func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transaction) error { // If there's no recipient, it's a contract // Check if this is a contract creation traction and if so // create a contract of this tx. @@ -115,10 +115,10 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac if contract != nil { sm.EvalScript(state, contract.Init(), contract, tx, block) } else { - ethutil.Config.Log.Infoln("[STATE] Unable to create contract") + return fmt.Errorf("[STATE] Unable to create contract") } } else { - ethutil.Config.Log.Infoln("[STATE] contract create:", err) + return fmt.Errorf("[STATE] contract create:", err) } } else { err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false) @@ -126,9 +126,11 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac if err == nil && contract != nil && len(contract.Script()) > 0 { sm.EvalScript(state, contract.Script(), contract, tx, block) } else if err != nil { - ethutil.Config.Log.Infoln("[STATE] process:", err) + return fmt.Errorf("[STATE] process:", err) } } + + return nil } func (sm *StateManager) Process(block *Block, dontReact bool) error { @@ -184,7 +186,7 @@ func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontRea //if !sm.compState.Cmp(state) { if !block.State().Cmp(state) { - return fmt.Errorf("Invalid merkle root. Expected %x, got %x", block.State().trie.Root, state.trie.Root) + return fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().trie.Root, state.trie.Root) } // Calculate the new total difficulty and sync back to the db |