Skip to content

Commit 3dc3cdb

Browse files
committed
config defaults
1 parent 845cccf commit 3dc3cdb

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

apps/fortuna/src/config.rs

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ pub struct EthereumConfig {
139139
pub priority_fee_multiplier_pct: u64,
140140

141141
/// The escalation policy governs how the gas limit and fee are increased during backoff retries.
142+
#[serde(default)]
142143
pub escalation_policy: EscalationPolicyConfig,
143144

144145
/// The minimum percentage profit to earn as a function of the callback cost.
@@ -202,6 +203,38 @@ pub struct EscalationPolicyConfig {
202203
pub fee_multiplier_cap_pct: u64,
203204
}
204205

206+
fn default_initial_gas_multiplier_pct() -> u64 {
207+
125
208+
}
209+
210+
fn default_gas_multiplier_pct() -> u64 {
211+
110
212+
}
213+
214+
fn default_gas_multiplier_cap_pct() -> u64 {
215+
600
216+
}
217+
218+
fn default_fee_multiplier_pct() -> u64 {
219+
110
220+
}
221+
222+
fn default_fee_multiplier_cap_pct() -> u64 {
223+
200
224+
}
225+
226+
impl Default for EscalationPolicyConfig {
227+
fn default() -> Self {
228+
Self {
229+
initial_gas_multiplier_pct: default_initial_gas_multiplier_pct(),
230+
gas_multiplier_pct: default_gas_multiplier_pct(),
231+
gas_multiplier_cap_pct: default_gas_multiplier_cap_pct(),
232+
fee_multiplier_pct: default_fee_multiplier_pct(),
233+
fee_multiplier_cap_pct: default_fee_multiplier_cap_pct(),
234+
}
235+
}
236+
}
237+
205238
impl EscalationPolicyConfig {
206239
pub fn get_gas_multiplier_pct(&self, num_retries: u64) -> u64 {
207240
self.apply_escalation_policy(
@@ -239,26 +272,6 @@ impl EscalationPolicyConfig {
239272
}
240273
}
241274

242-
fn default_initial_gas_multiplier_pct() -> u64 {
243-
125
244-
}
245-
246-
fn default_gas_multiplier_pct() -> u64 {
247-
110
248-
}
249-
250-
fn default_gas_multiplier_cap_pct() -> u64 {
251-
600
252-
}
253-
254-
fn default_fee_multiplier_pct() -> u64 {
255-
110
256-
}
257-
258-
fn default_fee_multiplier_cap_pct() -> u64 {
259-
200
260-
}
261-
262275
/// A commitment that the provider used to generate random numbers at some point in the past.
263276
/// These historical commitments need to be stored in the configuration to support transition points where
264277
/// the commitment changes. In theory, this information is stored on the blockchain, but unfortunately it

0 commit comments

Comments
 (0)