diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-01 16:41:30 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-01 16:41:30 +0800 |
commit | 7d0348e4baf45197ca506070e06e756a4ba6ccf6 (patch) | |
tree | 2f05e663ba1e3d7f8766f11c0b3fb1024fd3bed1 /ethchain/state_manager.go | |
parent | 7277c420479239fbea78417e42c43ee0162c2728 (diff) | |
download | dexon-7d0348e4baf45197ca506070e06e756a4ba6ccf6.tar.gz dexon-7d0348e4baf45197ca506070e06e756a4ba6ccf6.tar.zst dexon-7d0348e4baf45197ca506070e06e756a4ba6ccf6.zip |
Handle contract messages
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index d9831d49f..95e46e41d 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -114,13 +114,18 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) { // Figure out if the address this transaction was sent to is a // contract or an actual account. In case of a contract, we process that // contract instead of moving funds between accounts. + var err error if contract := sm.procState.GetContract(tx.Recipient); contract != nil { - sm.ProcessContract(contract, tx, block) - } else { - err := sm.Ethereum.TxPool().ProcessTransaction(tx, block) - if err != nil { - ethutil.Config.Log.Infoln("[STATE]", err) + err = sm.Ethereum.TxPool().ProcessTransaction(tx, sm.procState, true) + if err == nil { + sm.ProcessContract(contract, tx, block) } + } else { + err = sm.Ethereum.TxPool().ProcessTransaction(tx, sm.procState, false) + } + + if err != nil { + ethutil.Config.Log.Infoln("[STATE]", err) } } } @@ -318,4 +323,7 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo txData: nil, }) closure.Call(vm, nil) + + // Update the account (refunds) + sm.procState.UpdateAccount(tx.Sender(), caller) } |