From eded931bc475dc91c0b838171ed5ed3a15cbccf0 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Thu, 5 Dec 2024 16:10:48 +0100 Subject: [PATCH] Read gas price percentile from environment variable --- coreth/eth/ethconfig/config.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/coreth/eth/ethconfig/config.go b/coreth/eth/ethconfig/config.go index bb9c2671..33a99026 100644 --- a/coreth/eth/ethconfig/config.go +++ b/coreth/eth/ethconfig/config.go @@ -27,6 +27,8 @@ package ethconfig import ( + "os" + "strconv" "time" "github.com/ava-labs/coreth/core" @@ -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,