diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-18 22:33:22 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-18 22:33:22 +0800 |
commit | 5ad473d7581b92811c3a3e035274a82fc5568f57 (patch) | |
tree | 9d34ffc04b208a1923fa181938e7366bca2573d7 /core/state_transition.go | |
parent | db494170dc819b1eb0d267b6e1ab36c6cfb63569 (diff) | |
download | go-tangerine-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.gz go-tangerine-5ad473d7581b92811c3a3e035274a82fc5568f57.tar.zst go-tangerine-5ad473d7581b92811c3a3e035274a82fc5568f57.zip |
Moved methods to messages
Diffstat (limited to 'core/state_transition.go')
-rw-r--r-- | core/state_transition.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/state_transition.go b/core/state_transition.go index a6b654842..61c9558e3 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -44,8 +44,6 @@ type StateTransition struct { type Message interface { Hash() []byte - CreatesContract() bool - From() []byte To() []byte @@ -63,6 +61,10 @@ func AddressFromMessage(msg Message) []byte { return crypto.Sha3(ethutil.NewValue([]interface{}{msg.From(), msg.Nonce()}).Encode())[12:] } +func MessageCreatesContract(msg Message) bool { + return len(msg.To()) == 0 +} + func NewStateTransition(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition { return &StateTransition{coinbase.Address(), msg.To(), msg, new(big.Int), new(big.Int).Set(msg.GasPrice()), msg.Value(), msg.Data(), state, block, coinbase, nil, nil, nil} } @@ -93,7 +95,7 @@ func (self *StateTransition) From() *state.StateObject { return self.sen } func (self *StateTransition) To() *state.StateObject { - if self.msg != nil && self.msg.CreatesContract() { + if self.msg != nil && MessageCreatesContract(self.msg) { return nil } @@ -205,7 +207,7 @@ func (self *StateTransition) TransitionState() (err error) { var ret []byte vmenv := self.VmEnv() var ref vm.ClosureRef - if msg.CreatesContract() { + if MessageCreatesContract(msg) { self.rec = MakeContract(msg, self.state) ret, err, ref = vmenv.Create(sender, self.rec.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value) |