eth, rpc: add eth_minGasPrice to enable lower bounds on UIs

This commit is contained in:
Péter Szilágyi 2016-03-31 19:44:21 +03:00
parent 10d3466c93
commit 65f94a633f
3 changed files with 16 additions and 0 deletions

View file

@ -98,6 +98,11 @@ func NewPublicEthereumAPI(e *Ethereum) *PublicEthereumAPI {
return &PublicEthereumAPI{e, NewGasPriceOracle(e)}
}
// MinGasPrice returns te currently configured minimum gas price.
func (s *PublicEthereumAPI) MinGasPrice() *big.Int {
return s.gpo.MinimumPrice()
}
// GasPrice returns a suggestion for a gas price.
func (s *PublicEthereumAPI) GasPrice() *big.Int {
return s.gpo.SuggestPrice()

View file

@ -194,6 +194,12 @@ func (self *GasPriceOracle) lowestPrice(block *types.Block) *big.Int {
return minPrice
}
// MinimumPrice returns the configured minimum price that the oracle will ever
// return. This can be used as a bottom limit on UIs for fee selection sliders.
func (self *GasPriceOracle) MinimumPrice() *big.Int {
return new(big.Int).Set(self.minPrice)
}
// SuggestPrice returns the recommended gas price.
func (self *GasPriceOracle) SuggestPrice() *big.Int {
self.init()

View file

@ -251,6 +251,11 @@ web3._extend({
new web3._extend.Property({
name: 'pendingTransactions',
getter: 'eth_pendingTransactions'
}),
new web3._extend.Property({
name: 'minGasPrice',
getter: 'eth_minGasPrice',
outputFormatter: web3._extend.formatters.outputBigNumberFormatter
})
]
});