diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-14 17:46:09 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-14 17:46:09 +0800 |
commit | 63883bf27d8b87f601e1603e9024a279b91bffb7 (patch) | |
tree | be430bdebb7c73f761e9cded3f3600820dd8763c /ethchain/state_transition.go | |
parent | 81245473486dd680b7121d4b227ca8a57d07b4b1 (diff) | |
download | go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar.gz go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar.bz2 go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar.lz go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar.xz go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.tar.zst go-tangerine-63883bf27d8b87f601e1603e9024a279b91bffb7.zip |
Moving closer to interop
Diffstat (limited to 'ethchain/state_transition.go')
-rw-r--r-- | ethchain/state_transition.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index a080c5602..5ded0cddd 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -131,14 +131,21 @@ func (self *StateTransition) TransitionState() (err error) { return NonceError(tx.Nonce, sender.Nonce) } - // Increment the nonce for the next transaction - sender.Nonce += 1 - // Pre-pay gas / Buy gas of the coinbase account if err = self.BuyGas(); err != nil { return err } + // XXX Transactions after this point are considered valid. + + defer func() { + self.state.UpdateStateObject(sender) + self.state.UpdateStateObject(receiver) + }() + + // Increment the nonce for the next transaction + sender.Nonce += 1 + // Get the receiver (TODO fix this, if coinbase is the receiver we need to save/retrieve) receiver = self.Receiver() @@ -187,9 +194,6 @@ func (self *StateTransition) TransitionState() (err error) { remaining := new(big.Int).Mul(self.gas, tx.GasPrice) sender.AddAmount(remaining) - self.state.UpdateStateObject(sender) - self.state.UpdateStateObject(receiver) - return nil } |