v1.0.0
Overview
Package gas
provides two main ways to fetch a gas price from the ETH Gas Station API.
- Fetch the current recommended price for a given priority level with a new API call each time
- Use
gas.SuggestGasPrice
for a specific priority level - Use
gas.SuggestFastGasPrice
to fetch the fast priority level (no arguments)
- Use
- Create a new
GasPriceSuggester
which maintains a cache of results for a user-defined duration- Use
gas.NewGasPriceSuggester
and specify a max result age - Use the returned function to fetch new gas prices, or use the cache based on how old the results are
- Use
New in v1
- Adds a closure (
NewGasPriceSuggester
outer function) that allows user-defined max result age- Powered by
gasPriceManager
which maintains result cache, with max age - Thread safe inner function (of type
GasPriceSuggester
) - Adds tests for
gasPriceManager
which emulate functionality ofNewGasPriceSuggester
- Powered by
- Use
float64
type for ETH Gas Station API results rather thanjson.Number
- Allows simplification of private parsing method
Notes
- Thanks to @jalextowle for the initial implementation of
NewGasPriceSuggester