diff options
author | obscuren <geffobscura@gmail.com> | 2015-05-12 20:14:08 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-12 20:21:43 +0800 |
commit | 66de3f0aa849849c5cf5ad84265f3f3ce8ca5282 (patch) | |
tree | bef9ea4c2ff86fd1be3285812dcb9c02d19cde23 /xeth | |
parent | 96d4a7d0870ee019098cf1991b00f6959843e6fd (diff) | |
download | go-tangerine-66de3f0aa849849c5cf5ad84265f3f3ce8ca5282.tar.gz go-tangerine-66de3f0aa849849c5cf5ad84265f3f3ce8ca5282.tar.zst go-tangerine-66de3f0aa849849c5cf5ad84265f3f3ce8ca5282.zip |
xeth, rpc: implement eth_estimateGas. Closes #930
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/xeth.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index bf5844770..1ddd4c6e4 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -773,7 +773,7 @@ func (self *XEth) PushTx(encodedTx string) (string, error) { return tx.Hash().Hex(), nil } -func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) { +func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, string, error) { statedb := self.State().State() //self.eth.ChainManager().TransState() var from *state.StateObject if len(fromStr) == 0 { @@ -807,8 +807,10 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st block := self.CurrentBlock() vmenv := core.NewEnv(statedb, self.backend.ChainManager(), msg, block) + initialGas := new(big.Int).Set(msg.gas) res, err := vmenv.Call(msg.from, msg.to, msg.data, msg.gas, msg.gasPrice, msg.value) - return common.ToHex(res), err + + return common.ToHex(res), initialGas.Sub(initialGas, msg.gas).String(), err } func (self *XEth) ConfirmTransaction(tx string) bool { |