xeth: use same semantics as block processer for transient calls

This commit is contained in:
obscuren 2015-05-12 15:53:00 +02:00
parent 260536a729
commit ff99752ddd
1 changed files with 3 additions and 4 deletions

View File

@ -787,6 +787,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
from = statedb.GetOrNewStateObject(common.HexToAddress(fromStr)) from = statedb.GetOrNewStateObject(common.HexToAddress(fromStr))
} }
from.SetGasPool(self.backend.ChainManager().GasLimit())
msg := callmsg{ msg := callmsg{
from: from, from: from,
to: common.HexToAddress(toStr), to: common.HexToAddress(toStr),
@ -807,10 +808,8 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
block := self.CurrentBlock() block := self.CurrentBlock()
vmenv := core.NewEnv(statedb, self.backend.ChainManager(), msg, block) vmenv := core.NewEnv(statedb, self.backend.ChainManager(), msg, block)
initialGas := new(big.Int).Set(msg.gas) res, gas, err := core.ApplyMessage(vmenv, msg, from)
res, err := vmenv.Call(msg.from, msg.to, msg.data, msg.gas, msg.gasPrice, msg.value) return common.ToHex(res), gas.String(), err
return common.ToHex(res), initialGas.Sub(initialGas, msg.gas).String(), err
} }
func (self *XEth) ConfirmTransaction(tx string) bool { func (self *XEth) ConfirmTransaction(tx string) bool {