diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-20 06:45:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-20 06:45:44 +0800 |
commit | 09f37bd0235198145974db6430da0c429d2a0e79 (patch) | |
tree | c535bae31b23093031b42f62fcc82a50a3784ed8 /ethchain | |
parent | 8f29f6a4d4e2c62d3eff0dfd84cc8cab59dd28e8 (diff) | |
download | dexon-09f37bd0235198145974db6430da0c429d2a0e79.tar.gz dexon-09f37bd0235198145974db6430da0c429d2a0e79.tar.zst dexon-09f37bd0235198145974db6430da0c429d2a0e79.zip |
Returned to single method
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/state_transition.go | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index 5f4588e48..1f5b4f959 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -34,23 +34,6 @@ type StateTransition struct { cb, rec, sen *StateObject } -func Transition(coinbase, sender, receiver, data []byte, gas, gasPrice, value *big.Int, state *State, block *Block) (ret []byte, err error) { - stateTransition := &StateTransition{ - coinbase: coinbase, - receiver: receiver, - cb: state.GetOrNewStateObject(coinbase), - rec: state.GetOrNewStateObject(receiver), - sen: state.GetOrNewStateObject(sender), - gas: gas, - gasPrice: gasPrice, - value: value, - state: state, - block: block, - } - - return stateTransition.Transition() -} - func NewStateTransition(coinbase *StateObject, tx *Transaction, state *State, block *Block) *StateTransition { return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil} } @@ -168,20 +151,14 @@ func (self *StateTransition) TransitionState() (err error) { return } - defer self.RefundGas() - - _, err = self.Transition() - - return -} - -func (self *StateTransition) Transition() (ret []byte, err error) { var ( tx = self.tx sender = self.Sender() receiver *StateObject ) + defer self.RefundGas() + // Increment the nonce for the next transaction sender.Nonce += 1 @@ -204,7 +181,7 @@ func (self *StateTransition) Transition() (ret []byte, err error) { // Create a new state object for the contract receiver = self.MakeStateObject(self.state, tx) if receiver == nil { - return nil, fmt.Errorf("Unable to create contract") + return fmt.Errorf("Unable to create contract") } } @@ -224,18 +201,18 @@ func (self *StateTransition) Transition() (ret []byte, err error) { if err != nil || deepErr { self.state.ResetStateObject(receiver) - return nil, fmt.Errorf("Error during init script run %v (deepErr = %v)", err, deepErr) + return fmt.Errorf("Error during init script run %v (deepErr = %v)", err, deepErr) } receiver.script = code } else { if len(receiver.Script()) > 0 { var deepErr bool - ret, err, deepErr = self.Eval(receiver.Script(), receiver) + _, err, deepErr = self.Eval(receiver.Script(), receiver) if err != nil { self.state.ResetStateObject(receiver) - return nil, fmt.Errorf("Error during code execution %v (deepErr = %v)", err, deepErr) + return fmt.Errorf("Error during code execution %v (deepErr = %v)", err, deepErr) } } } |