Skip to content

Commit

Permalink
Convert gas price to gwei
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 committed Oct 22, 2024
1 parent 9260696 commit 3fa0518
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions chains/evm/transactor/monitored/monitored.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ type RawTx struct {
creationTime time.Time
}

// GasPrice returns transaction gas price in gwei
func (tx *RawTx) GasPrice() *big.Int {
var gasPrice *big.Int
if len(tx.gasPrice) == 1 {
return tx.gasPrice[0]
gasPrice = tx.gasPrice[0]
} else {
return tx.gasPrice[1]
gasPrice = tx.gasPrice[1]
}
return new(big.Int).Div(gasPrice, big.NewInt(1e9))
}

type MonitoredTransactor struct {
Expand Down
3 changes: 1 addition & 2 deletions observability/metrics/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ func NewNetworkMetrics(ctx context.Context, meter metric.Meter, opts metric.Meas

gasPriceHistogram, err := meter.Int64Histogram(
"relayer.GasPrice",
metric.WithDescription("Gas price distribution per transaction."),
metric.WithUnit("gas"),
metric.WithDescription("Gas price distribution per transaction in gwei."),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 3fa0518

Please sign in to comment.