diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 16:36:37 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 16:36:37 +0800 |
commit | 537774e049f82ae90a4ef0c21d590acb6e892f17 (patch) | |
tree | 3587c8f8f9d8e6efe2af6ed565ffc4851f4d5dea /eth/api.go | |
parent | 1cc4bd76dbec6da4355a37cf68de808fcf0c95a3 (diff) | |
parent | 725f2a4cf74c8af49ef85ca49202cbdfdccc0589 (diff) | |
download | go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar.gz go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar.bz2 go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar.lz go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar.xz go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.tar.zst go-tangerine-537774e049f82ae90a4ef0c21d590acb6e892f17.zip |
Merge pull request #2195 from obscuren/gpo-rpc
eth: Added GPO to suggest default gas prices
Diffstat (limited to 'eth/api.go')
-rw-r--r-- | eth/api.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/eth/api.go b/eth/api.go index 3c01e2c11..37b033dc6 100644 --- a/eth/api.go +++ b/eth/api.go @@ -47,10 +47,7 @@ import ( "gopkg.in/fatih/set.v0" ) -const ( - defaultGasPrice = uint64(10000000000000) - defaultGas = uint64(90000) -) +const defaultGas = uint64(90000) // blockByNumber is a commonly used helper function which retrieves and returns // the block for the given block number, capable of handling two special blocks: @@ -820,6 +817,7 @@ func newRPCTransaction(b *types.Block, txHash common.Hash) (*RPCTransaction, err type PublicTransactionPoolAPI struct { eventMux *event.TypeMux chainDb ethdb.Database + gpo *GasPriceOracle bc *core.BlockChain miner *miner.Miner am *accounts.Manager @@ -828,14 +826,15 @@ type PublicTransactionPoolAPI struct { } // NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool. -func NewPublicTransactionPoolAPI(txPool *core.TxPool, m *miner.Miner, chainDb ethdb.Database, eventMux *event.TypeMux, bc *core.BlockChain, am *accounts.Manager) *PublicTransactionPoolAPI { +func NewPublicTransactionPoolAPI(e *Ethereum) *PublicTransactionPoolAPI { return &PublicTransactionPoolAPI{ - eventMux: eventMux, - chainDb: chainDb, - bc: bc, - am: am, - txPool: txPool, - miner: m, + eventMux: e.EventMux(), + gpo: NewGasPriceOracle(e), + chainDb: e.ChainDb(), + bc: e.BlockChain(), + am: e.AccountManager(), + txPool: e.TxPool(), + miner: e.Miner(), } } @@ -1028,7 +1027,7 @@ func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash args.Gas = rpc.NewHexNumber(defaultGas) } if args.GasPrice == nil { - args.GasPrice = rpc.NewHexNumber(defaultGasPrice) + args.GasPrice = rpc.NewHexNumber(s.gpo.SuggestPrice()) } if args.Value == nil { args.Value = rpc.NewHexNumber(0) @@ -1169,7 +1168,7 @@ func (tx *Tx) UnmarshalJSON(b []byte) (err error) { tx.GasLimit = rpc.NewHexNumber(0) } if tx.GasPrice == nil { - tx.GasPrice = rpc.NewHexNumber(defaultGasPrice) + tx.GasPrice = rpc.NewHexNumber(int64(50000000000)) } if contractCreation { @@ -1212,7 +1211,7 @@ func (s *PublicTransactionPoolAPI) SignTransaction(args *SignTransactionArgs) (* args.Gas = rpc.NewHexNumber(defaultGas) } if args.GasPrice == nil { - args.GasPrice = rpc.NewHexNumber(defaultGasPrice) + args.GasPrice = rpc.NewHexNumber(s.gpo.SuggestPrice()) } if args.Value == nil { args.Value = rpc.NewHexNumber(0) |