aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state_manager.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-21 06:17:50 +0800
committerobscuren <geffobscura@gmail.com>2014-05-21 06:17:50 +0800
commit5ceb1620e93e1999c6f72e6164c7c65af63244ec (patch)
treee3185f8202dd3f3ebd065be5a1ea7e7ba08e6055 /ethchain/state_manager.go
parente8b45852952138ac24dada1a70480d31d0886c27 (diff)
downloaddexon-5ceb1620e93e1999c6f72e6164c7c65af63244ec.tar.gz
dexon-5ceb1620e93e1999c6f72e6164c7c65af63244ec.tar.zst
dexon-5ceb1620e93e1999c6f72e6164c7c65af63244ec.zip
Fixed couple issues
* (imp) Lock / RLock tries * (fix) stack
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r--ethchain/state_manager.go46
1 files changed, 25 insertions, 21 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index c7c6857d8..27eaa5e60 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -100,30 +100,34 @@ func (sm *StateManager) MakeContract(state *State, tx *Transaction) *StateObject
func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Transaction) {
// Process each transaction/contract
for _, tx := range txs {
- // 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.
- if tx.IsContract() {
- err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
- if err == nil {
- contract := sm.MakeContract(state, tx)
- if contract != nil {
- sm.EvalScript(state, contract.Init(), contract, tx, block)
- } else {
- ethutil.Config.Log.Infoln("[STATE] Unable to create contract")
- }
+ sm.ApplyTransaction(state, block, tx)
+ }
+}
+
+func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transaction) {
+ // 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.
+ if tx.IsContract() {
+ err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
+ if err == nil {
+ contract := sm.MakeContract(state, tx)
+ if contract != nil {
+ sm.EvalScript(state, contract.Init(), contract, tx, block)
} else {
- ethutil.Config.Log.Infoln("[STATE] contract create:", err)
+ ethutil.Config.Log.Infoln("[STATE] Unable to create contract")
}
} else {
- err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
- contract := state.GetStateObject(tx.Recipient)
- ethutil.Config.Log.Debugf("contract recip %x\n", tx.Recipient)
- if err == nil && len(contract.Script()) > 0 {
- sm.EvalScript(state, contract.Script(), contract, tx, block)
- } else if err != nil {
- ethutil.Config.Log.Infoln("[STATE] process:", err)
- }
+ ethutil.Config.Log.Infoln("[STATE] contract create:", err)
+ }
+ } else {
+ err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
+ contract := state.GetStateObject(tx.Recipient)
+ ethutil.Config.Log.Debugf("contract recip %x\n", tx.Recipient)
+ if err == nil && len(contract.Script()) > 0 {
+ sm.EvalScript(state, contract.Script(), contract, tx, block)
+ } else if err != nil {
+ ethutil.Config.Log.Infoln("[STATE] process:", err)
}
}
}