diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-11-13 19:47:27 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-01-03 20:45:35 +0800 |
commit | 6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 (patch) | |
tree | c92974f8b82209073ad1ee3faec6e149f834bf69 /mobile | |
parent | b8caba97099ee5eed33c3b80dd4ea540722e7d8f (diff) | |
download | go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.gz go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.zst go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.zip |
all: switch gas limits from big.Int to uint64
Diffstat (limited to 'mobile')
-rw-r--r-- | mobile/bind.go | 4 | ||||
-rw-r--r-- | mobile/ethclient.go | 4 | ||||
-rw-r--r-- | mobile/ethereum.go | 5 | ||||
-rw-r--r-- | mobile/types.go | 28 |
4 files changed, 20 insertions, 21 deletions
diff --git a/mobile/bind.go b/mobile/bind.go index 7b79bedaf..1e861d0bc 100644 --- a/mobile/bind.go +++ b/mobile/bind.go @@ -77,7 +77,7 @@ func (opts *TransactOpts) GetFrom() *Address { return &Address{opts.opts.From func (opts *TransactOpts) GetNonce() int64 { return opts.opts.Nonce.Int64() } func (opts *TransactOpts) GetValue() *BigInt { return &BigInt{opts.opts.Value} } func (opts *TransactOpts) GetGasPrice() *BigInt { return &BigInt{opts.opts.GasPrice} } -func (opts *TransactOpts) GetGasLimit() int64 { return opts.opts.GasLimit.Int64() } +func (opts *TransactOpts) GetGasLimit() int64 { return int64(opts.opts.GasLimit) } // GetSigner cannot be reliably implemented without identity preservation (https://github.com/golang/go/issues/16876) // func (opts *TransactOpts) GetSigner() Signer { return &signer{opts.opts.Signer} } @@ -99,7 +99,7 @@ func (opts *TransactOpts) SetSigner(s Signer) { } func (opts *TransactOpts) SetValue(value *BigInt) { opts.opts.Value = value.bigint } func (opts *TransactOpts) SetGasPrice(price *BigInt) { opts.opts.GasPrice = price.bigint } -func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = big.NewInt(limit) } +func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = uint64(limit) } func (opts *TransactOpts) SetContext(context *Context) { opts.opts.Context = context.context } // BoundContract is the base wrapper object that reflects a contract on the diff --git a/mobile/ethclient.go b/mobile/ethclient.go index 758863b6d..66399c6b5 100644 --- a/mobile/ethclient.go +++ b/mobile/ethclient.go @@ -298,9 +298,9 @@ func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (price *BigInt, _ error) // the current pending state of the backend blockchain. There is no guarantee that this is // the true gas limit requirement as other transactions may be added or removed by miners, // but it should provide a basis for setting a reasonable default. -func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (gas *BigInt, _ error) { +func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (gas int64, _ error) { rawGas, err := ec.client.EstimateGas(ctx.context, msg.msg) - return &BigInt{rawGas}, err + return int64(rawGas), err } // SendTransaction injects a signed transaction into the pending pool for execution. diff --git a/mobile/ethereum.go b/mobile/ethereum.go index c9bb3013c..0eb1d9055 100644 --- a/mobile/ethereum.go +++ b/mobile/ethereum.go @@ -20,7 +20,6 @@ package geth import ( "errors" - "math/big" ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" @@ -49,7 +48,7 @@ func NewCallMsg() *CallMsg { } func (msg *CallMsg) GetFrom() *Address { return &Address{msg.msg.From} } -func (msg *CallMsg) GetGas() int64 { return msg.msg.Gas.Int64() } +func (msg *CallMsg) GetGas() int64 { return int64(msg.msg.Gas) } func (msg *CallMsg) GetGasPrice() *BigInt { return &BigInt{msg.msg.GasPrice} } func (msg *CallMsg) GetValue() *BigInt { return &BigInt{msg.msg.Value} } func (msg *CallMsg) GetData() []byte { return msg.msg.Data } @@ -61,7 +60,7 @@ func (msg *CallMsg) GetTo() *Address { } func (msg *CallMsg) SetFrom(address *Address) { msg.msg.From = address.address } -func (msg *CallMsg) SetGas(gas int64) { msg.msg.Gas = big.NewInt(gas) } +func (msg *CallMsg) SetGas(gas int64) { msg.msg.Gas = uint64(gas) } func (msg *CallMsg) SetGasPrice(price *BigInt) { msg.msg.GasPrice = price.bigint } func (msg *CallMsg) SetValue(value *BigInt) { msg.msg.Value = value.bigint } func (msg *CallMsg) SetData(data []byte) { msg.msg.Data = common.CopyBytes(data) } diff --git a/mobile/types.go b/mobile/types.go index b7f8a3bc1..4790afcef 100644 --- a/mobile/types.go +++ b/mobile/types.go @@ -112,8 +112,8 @@ func (h *Header) GetReceiptHash() *Hash { return &Hash{h.header.ReceiptHash} } func (h *Header) GetBloom() *Bloom { return &Bloom{h.header.Bloom} } func (h *Header) GetDifficulty() *BigInt { return &BigInt{h.header.Difficulty} } func (h *Header) GetNumber() int64 { return h.header.Number.Int64() } -func (h *Header) GetGasLimit() int64 { return h.header.GasLimit.Int64() } -func (h *Header) GetGasUsed() int64 { return h.header.GasUsed.Int64() } +func (h *Header) GetGasLimit() int64 { return int64(h.header.GasLimit) } +func (h *Header) GetGasUsed() int64 { return int64(h.header.GasUsed) } func (h *Header) GetTime() int64 { return h.header.Time.Int64() } func (h *Header) GetExtra() []byte { return h.header.Extra } func (h *Header) GetMixDigest() *Hash { return &Hash{h.header.MixDigest} } @@ -189,8 +189,8 @@ func (b *Block) GetReceiptHash() *Hash { return &Hash{b.block.ReceiptHash()} } func (b *Block) GetBloom() *Bloom { return &Bloom{b.block.Bloom()} } func (b *Block) GetDifficulty() *BigInt { return &BigInt{b.block.Difficulty()} } func (b *Block) GetNumber() int64 { return b.block.Number().Int64() } -func (b *Block) GetGasLimit() int64 { return b.block.GasLimit().Int64() } -func (b *Block) GetGasUsed() int64 { return b.block.GasUsed().Int64() } +func (b *Block) GetGasLimit() int64 { return int64(b.block.GasLimit()) } +func (b *Block) GetGasUsed() int64 { return int64(b.block.GasUsed()) } func (b *Block) GetTime() int64 { return b.block.Time().Int64() } func (b *Block) GetExtra() []byte { return b.block.Extra() } func (b *Block) GetMixDigest() *Hash { return &Hash{b.block.MixDigest()} } @@ -212,8 +212,8 @@ type Transaction struct { } // NewTransaction creates a new transaction with the given properties. -func NewTransaction(nonce int64, to *Address, amount, gasLimit, gasPrice *BigInt, data []byte) *Transaction { - return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, gasLimit.bigint, gasPrice.bigint, common.CopyBytes(data))} +func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction { + return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))} } // NewTransactionFromRLP parses a transaction from an RLP data dump. @@ -256,7 +256,7 @@ func (tx *Transaction) String() string { } func (tx *Transaction) GetData() []byte { return tx.tx.Data() } -func (tx *Transaction) GetGas() int64 { return tx.tx.Gas().Int64() } +func (tx *Transaction) GetGas() int64 { return int64(tx.tx.Gas()) } func (tx *Transaction) GetGasPrice() *BigInt { return &BigInt{tx.tx.GasPrice()} } func (tx *Transaction) GetValue() *BigInt { return &BigInt{tx.tx.Value()} } func (tx *Transaction) GetNonce() int64 { return int64(tx.tx.Nonce()) } @@ -353,10 +353,10 @@ func (r *Receipt) String() string { return r.receipt.String() } -func (r *Receipt) GetPostState() []byte { return r.receipt.PostState } -func (r *Receipt) GetCumulativeGasUsed() *BigInt { return &BigInt{r.receipt.CumulativeGasUsed} } -func (r *Receipt) GetBloom() *Bloom { return &Bloom{r.receipt.Bloom} } -func (r *Receipt) GetLogs() *Logs { return &Logs{r.receipt.Logs} } -func (r *Receipt) GetTxHash() *Hash { return &Hash{r.receipt.TxHash} } -func (r *Receipt) GetContractAddress() *Address { return &Address{r.receipt.ContractAddress} } -func (r *Receipt) GetGasUsed() *BigInt { return &BigInt{r.receipt.GasUsed} } +func (r *Receipt) GetPostState() []byte { return r.receipt.PostState } +func (r *Receipt) GetCumulativeGasUsed() int64 { return int64(r.receipt.CumulativeGasUsed) } +func (r *Receipt) GetBloom() *Bloom { return &Bloom{r.receipt.Bloom} } +func (r *Receipt) GetLogs() *Logs { return &Logs{r.receipt.Logs} } +func (r *Receipt) GetTxHash() *Hash { return &Hash{r.receipt.TxHash} } +func (r *Receipt) GetContractAddress() *Address { return &Address{r.receipt.ContractAddress} } +func (r *Receipt) GetGasUsed() int64 { return int64(r.receipt.GasUsed) } |