-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2310 from rsksmart/feature/include_stable_minGasP…
…rice_provider Configurable Fiat-Based Stable MinGasPrice
- Loading branch information
Showing
37 changed files
with
1,852 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
rskj-core/src/main/java/co/rsk/config/mining/EthCallMinGasPriceSystemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of RskJ | ||
* Copyright (C) 2024 RSK Labs Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package co.rsk.config.mining; | ||
|
||
import com.typesafe.config.Config; | ||
|
||
public class EthCallMinGasPriceSystemConfig { | ||
private static final String FROM_PROPERTY = "from"; | ||
private static final String TO_PROPERTY = "to"; | ||
private static final String DATA_PROPERTY = "data"; | ||
private final String address; | ||
private final String from; | ||
private final String data; | ||
|
||
public EthCallMinGasPriceSystemConfig(Config config) { | ||
address = config.getString(TO_PROPERTY); | ||
from = config.getString(FROM_PROPERTY); | ||
data = config.getString(DATA_PROPERTY); | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public String getFrom() { | ||
return from; | ||
} | ||
|
||
public String getData() { | ||
return data; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
rskj-core/src/main/java/co/rsk/config/mining/HttpGetStableMinGasSystemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* This file is part of RskJ | ||
* Copyright (C) 2024 RSK Labs Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package co.rsk.config.mining; | ||
|
||
import com.typesafe.config.Config; | ||
|
||
import java.time.Duration; | ||
import java.util.Objects; | ||
|
||
public class HttpGetStableMinGasSystemConfig { | ||
private static final String URL_PROPERTY = "url"; | ||
private static final String JSON_PATH = "jsonPath"; | ||
private static final String TIMEOUT_PROPERTY = "timeout"; | ||
|
||
private final String url; | ||
private final String jsonPath; | ||
private final Duration timeout; | ||
|
||
public HttpGetStableMinGasSystemConfig(Config config) { | ||
this.url = Objects.requireNonNull(config.getString(URL_PROPERTY)); | ||
this.jsonPath = Objects.requireNonNull(config.getString(JSON_PATH)); | ||
this.timeout = Objects.requireNonNull(config.getDuration(TIMEOUT_PROPERTY)); | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getJsonPath() { | ||
return jsonPath; | ||
} | ||
|
||
public Duration getTimeout() { | ||
return timeout; | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
rskj-core/src/main/java/co/rsk/config/mining/StableMinGasPriceSystemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This file is part of RskJ | ||
* Copyright (C) 2024 RSK Labs Ltd. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package co.rsk.config.mining; | ||
|
||
import co.rsk.mine.gas.provider.MinGasPriceProviderType; | ||
import com.typesafe.config.Config; | ||
|
||
import java.time.Duration; | ||
|
||
public class StableMinGasPriceSystemConfig { | ||
public static final String STABLE_GAS_PRICE_CONFIG_PATH_PROPERTY = "miner.stableGasPrice"; | ||
|
||
private static final String ENABLED_PROPERTY = "enabled"; | ||
private static final String REFRESH_RATE_PROPERTY = "refreshRate"; | ||
private static final String MIN_STABLE_GAS_PRICE_PROPERTY = "minStableGasPrice"; | ||
private static final String METHOD_PROPERTY = "source.method"; | ||
private static final String PARAMS_PROPERTY = "source.params"; | ||
|
||
private final Duration refreshRate; | ||
private final Long minStableGasPrice; | ||
private final boolean enabled; | ||
private final MinGasPriceProviderType method; | ||
private final Config config; | ||
|
||
public StableMinGasPriceSystemConfig(Config config) { | ||
this.enabled = config.hasPath(ENABLED_PROPERTY) && config.getBoolean(ENABLED_PROPERTY); | ||
this.refreshRate = this.enabled && config.hasPath(REFRESH_RATE_PROPERTY) ? config.getDuration(REFRESH_RATE_PROPERTY) : Duration.ZERO; | ||
this.minStableGasPrice = this.enabled && config.hasPath(MIN_STABLE_GAS_PRICE_PROPERTY) ? config.getLong(MIN_STABLE_GAS_PRICE_PROPERTY) : 0; | ||
this.method = this.enabled ? config.getEnum(MinGasPriceProviderType.class, METHOD_PROPERTY) : MinGasPriceProviderType.FIXED; | ||
this.config = config; | ||
} | ||
|
||
public Duration getRefreshRate() { | ||
return refreshRate; | ||
} | ||
|
||
public Long getMinStableGasPrice() { | ||
return minStableGasPrice; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public HttpGetStableMinGasSystemConfig getHttpGetConfig() { | ||
return new HttpGetStableMinGasSystemConfig(config.getConfig(PARAMS_PROPERTY)); | ||
} | ||
|
||
public EthCallMinGasPriceSystemConfig getEthCallConfig() { | ||
return new EthCallMinGasPriceSystemConfig(config.getConfig(PARAMS_PROPERTY)); | ||
} | ||
|
||
public MinGasPriceProviderType getMethod() { | ||
return method; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.