Skip to content

Commit a90d34c

Browse files
author
Jiri Malek
committed
Offer gas price in more precise units.
1 parent 1af3522 commit a90d34c

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

internal/repository/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/ethereum/go-ethereum/common"
1616
"github.com/ethereum/go-ethereum/common/hexutil"
1717
"io/ioutil"
18+
"math"
1819
"net/http"
1920
"strings"
2021
"time"
@@ -44,7 +45,7 @@ func (p *proxy) GasPriceExtended() (*types.GasPrice, error) {
4445
}
4546

4647
// calculate the gas price in Gwei units
47-
gWei := int32(uint64(gp) / uint64(1000000000))
48+
gWei := math.Round(float64(gp)/float64(100000000)) / 10.0
4849
return &types.GasPrice{
4950
Fast: gWei,
5051
Fastest: gWei,

internal/types/gas_price.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package types
33

44
// GasPrice represents an extended gas price estimator.
55
type GasPrice struct {
6-
Fast int32 `json:"fast"`
7-
Fastest int32 `json:"fastest"`
8-
SafeLow int32 `json:"safeLow"`
9-
Average int32 `json:"average"`
6+
Fast float64 `json:"fast"`
7+
Fastest float64 `json:"fastest"`
8+
SafeLow float64 `json:"safeLow"`
9+
Average float64 `json:"average"`
1010
}

0 commit comments

Comments
 (0)