From d560e6920333c522b8f2ddc7cbc193c8ab1c8b21 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 11 Mar 2021 14:59:57 +1100 Subject: [PATCH] Make durations more readable by using extension methods from `time` --- swap/src/execution_params.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/swap/src/execution_params.rs b/swap/src/execution_params.rs index a42da3f5..5b6f017b 100644 --- a/swap/src/execution_params.rs +++ b/swap/src/execution_params.rs @@ -1,5 +1,6 @@ use crate::bitcoin::{CancelTimelock, PunishTimelock}; use std::time::Duration; +use time::NumericalStdDurationShort; #[derive(Debug, Copy, Clone)] pub struct ExecutionParams { @@ -27,9 +28,9 @@ pub struct Regtest; impl GetExecutionParams for Mainnet { fn get_execution_params() -> ExecutionParams { ExecutionParams { - bob_time_to_act: Duration::from_secs(10 * 60), + bob_time_to_act: 10.minutes(), bitcoin_finality_confirmations: 3, - bitcoin_avg_block_time: Duration::from_secs(10 * 60), + bitcoin_avg_block_time: 10.minutes(), monero_finality_confirmations: 15, bitcoin_cancel_timelock: CancelTimelock::new(72), bitcoin_punish_timelock: PunishTimelock::new(72), @@ -40,9 +41,9 @@ impl GetExecutionParams for Mainnet { impl GetExecutionParams for Testnet { fn get_execution_params() -> ExecutionParams { ExecutionParams { - bob_time_to_act: Duration::from_secs(60 * 60), + bob_time_to_act: 60.minutes(), bitcoin_finality_confirmations: 1, - bitcoin_avg_block_time: Duration::from_secs(5 * 60), + bitcoin_avg_block_time: 5.minutes(), monero_finality_confirmations: 10, bitcoin_cancel_timelock: CancelTimelock::new(12), bitcoin_punish_timelock: PunishTimelock::new(6), @@ -53,9 +54,9 @@ impl GetExecutionParams for Testnet { impl GetExecutionParams for Regtest { fn get_execution_params() -> ExecutionParams { ExecutionParams { - bob_time_to_act: Duration::from_secs(30), + bob_time_to_act: 30.seconds(), bitcoin_finality_confirmations: 1, - bitcoin_avg_block_time: Duration::from_secs(5), + bitcoin_avg_block_time: 5.seconds(), monero_finality_confirmations: 10, bitcoin_cancel_timelock: CancelTimelock::new(100), bitcoin_punish_timelock: PunishTimelock::new(50),