Skip to content

Commit

Permalink
Read gas price percentile from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Boben committed Dec 5, 2024
1 parent 10e9520 commit eded931
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions coreth/eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
package ethconfig

import (
"os"
"strconv"
"time"

"github.com/ava-labs/coreth/core"
Expand Down Expand Up @@ -60,6 +62,18 @@ var DefaultFullGPOSgbConfig = gasprice.Config{
// DefaultConfig contains default settings for use on the Avalanche main net.
var DefaultConfig = NewDefaultConfig()

func init() {
// Set the gas price percentile from the environment variable "GAS_PRICE_PERCENTILE"
if gasPricePercentileStr := os.Getenv("GAS_PRICE_PERCENTILE"); gasPricePercentileStr != "" {
gasPricePercentile, err := strconv.Atoi(gasPricePercentileStr)
if err != nil || gasPricePercentile < 0 || gasPricePercentile > 100 {
panic("GAS_PRICE_PERCENTILE must be a value between 0 and 100")
}
DefaultFullGPOConfig.Percentile = gasPricePercentile
DefaultFullGPOSgbConfig.Percentile = gasPricePercentile
}
}

func NewDefaultConfig() Config {
return Config{
NetworkId: 1,
Expand Down

0 comments on commit eded931

Please sign in to comment.