mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
Configure Gas Price Oracle with CLI arguments (#2664)
Co-authored-by: Aditya Pandey <aditya.p@Aditya-P.local> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -46,3 +46,11 @@ impl Default for EthConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EthConfig {
|
||||
/// Configures the gas price oracle settings
|
||||
pub fn with_gpo_config(mut self, gas_oracle_config: GasPriceOracleConfig) -> Self {
|
||||
self.gas_oracle = gas_oracle_config;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,6 +349,10 @@ impl RpcModuleConfig {
|
||||
pub fn builder() -> RpcModuleConfigBuilder {
|
||||
RpcModuleConfigBuilder::default()
|
||||
}
|
||||
/// Returns a new RPC module config given the eth namespace config
|
||||
pub fn new(eth: EthConfig) -> Self {
|
||||
Self { eth }
|
||||
}
|
||||
}
|
||||
|
||||
/// Configures [RpcModuleConfig]
|
||||
|
||||
@@ -59,6 +59,26 @@ impl Default for GasPriceOracleConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl GasPriceOracleConfig {
|
||||
/// Creating a new gpo config with blocks, ignoreprice, maxprice and percentile
|
||||
pub fn new(
|
||||
blocks: Option<u32>,
|
||||
ignore_price: Option<u64>,
|
||||
max_price: Option<u64>,
|
||||
percentile: Option<u32>,
|
||||
) -> Self {
|
||||
Self {
|
||||
blocks: blocks.unwrap_or(20),
|
||||
percentile: percentile.unwrap_or(60),
|
||||
max_header_history: 1024,
|
||||
max_block_history: 1024,
|
||||
default: None,
|
||||
max_price: max_price.map(U256::from).or(Some(DEFAULT_MAX_PRICE)),
|
||||
ignore_price: ignore_price.map(U256::from).or(Some(DEFAULT_IGNORE_PRICE)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates a gas price depending on recent blocks.
|
||||
#[derive(Debug)]
|
||||
pub struct GasPriceOracle<Client> {
|
||||
|
||||
Reference in New Issue
Block a user