aboutsummaryrefslogtreecommitdiffstats
path: root/core/state_transition.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-17 18:19:23 +0800
committerobscuren <geffobscura@gmail.com>2015-03-17 18:19:23 +0800
commit515d9432fcef8c574627049d437d6898b56c2829 (patch)
tree40322c532a38b8f563d452bd75dab69729e55d92 /core/state_transition.go
parent8ce6a3647821706cf5e9bb1a9dc13f23c84f6585 (diff)
downloaddexon-515d9432fcef8c574627049d437d6898b56c2829.tar.gz
dexon-515d9432fcef8c574627049d437d6898b56c2829.tar.zst
dexon-515d9432fcef8c574627049d437d6898b56c2829.zip
converted vm
Diffstat (limited to 'core/state_transition.go')
-rw-r--r--core/state_transition.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/state_transition.go b/core/state_transition.go
index 575bdf026..ce9835751 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -31,7 +31,7 @@ var ()
* 6) Derive new state root
*/
type StateTransition struct {
- coinbase []byte
+ coinbase common.Address
msg Message
gas, gasPrice *big.Int
initialGas *big.Int
@@ -119,7 +119,7 @@ func (self *StateTransition) BuyGas() error {
sender := self.From()
if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
- return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address()[:4], MessageGasValue(self.msg), sender.Balance())
+ return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address().Bytes()[:4], MessageGasValue(self.msg), sender.Balance())
}
coinbase := self.Coinbase()
@@ -195,8 +195,9 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
vmenv := self.env
var ref vm.ContextRef
if MessageCreatesContract(msg) {
- contract := makeContract(msg, self.state)
- ret, err, ref = vmenv.Create(sender, contract.Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
+ //contract := makeContract(msg, self.state)
+ //addr := contract.Address()
+ ret, err, ref = vmenv.Create(sender, self.msg.Data(), self.gas, self.gasPrice, self.value)
if err == nil {
dataGas := big.NewInt(int64(len(ret)))
dataGas.Mul(dataGas, vm.GasCreateByte)
@@ -230,7 +231,7 @@ func (self *StateTransition) refundGas() {
for addr, ref := range self.state.Refunds() {
refund := common.BigMin(uhalf, ref)
self.gas.Add(self.gas, refund)
- self.state.AddBalance([]byte(addr), refund.Mul(refund, self.msg.GasPrice()))
+ self.state.AddBalance(common.StringToAddress(addr), refund.Mul(refund, self.msg.GasPrice()))
}
coinbase.RefundGas(self.gas, self.msg.GasPrice())
@@ -242,10 +243,13 @@ func (self *StateTransition) gasUsed() *big.Int {
// Converts an message in to a state object
func makeContract(msg Message, state *state.StateDB) *state.StateObject {
- addr := AddressFromMessage(msg)
+ /*
+ addr := AddressFromMessage(msg)
- contract := state.GetOrNewStateObject(addr)
- contract.SetInitCode(msg.Data())
+ contract := state.GetOrNewStateObject(addr)
+ contract.SetInitCode(msg.Data())
- return contract
+ return contract
+ */
+ return nil
}