From 9220cdcef121aa039c7bfae2e147902a5369be44 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 29 Jul 2024 11:21:24 +0100 Subject: [PATCH] fix(consensus): use Duration for max base time --- .../tari_dan_app_utilities/src/consensus_constants.rs | 4 ++-- dan_layer/consensus/src/hotstuff/config.rs | 2 +- dan_layer/consensus/src/hotstuff/pacemaker.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/tari_dan_app_utilities/src/consensus_constants.rs b/applications/tari_dan_app_utilities/src/consensus_constants.rs index 981dfc17e0..1c943b5262 100644 --- a/applications/tari_dan_app_utilities/src/consensus_constants.rs +++ b/applications/tari_dan_app_utilities/src/consensus_constants.rs @@ -26,7 +26,7 @@ pub struct ConsensusConstants { pub committee_size: u32, pub max_base_layer_blocks_ahead: u64, pub max_base_layer_blocks_behind: u64, - pub pacemaker_max_base_time: u64, // GST in seconds for consensus + pub pacemaker_max_base_time: std::time::Duration, } impl ConsensusConstants { @@ -36,7 +36,7 @@ impl ConsensusConstants { committee_size: 7, max_base_layer_blocks_ahead: 5, max_base_layer_blocks_behind: 5, - pacemaker_max_base_time: 10, + pacemaker_max_base_time: std::time::Duration::from_secs(10), } } } diff --git a/dan_layer/consensus/src/hotstuff/config.rs b/dan_layer/consensus/src/hotstuff/config.rs index 25b6987fd4..1b33991c8d 100644 --- a/dan_layer/consensus/src/hotstuff/config.rs +++ b/dan_layer/consensus/src/hotstuff/config.rs @@ -5,5 +5,5 @@ pub struct HotstuffConfig { pub max_base_layer_blocks_ahead: u64, pub max_base_layer_blocks_behind: u64, - pub pacemaker_max_base_time: u64, + pub pacemaker_max_base_time: std::time::Duration, } diff --git a/dan_layer/consensus/src/hotstuff/pacemaker.rs b/dan_layer/consensus/src/hotstuff/pacemaker.rs index ad7841b4bf..b3c6b24714 100644 --- a/dan_layer/consensus/src/hotstuff/pacemaker.rs +++ b/dan_layer/consensus/src/hotstuff/pacemaker.rs @@ -31,7 +31,7 @@ pub struct PaceMaker { } impl PaceMaker { - pub fn new(max_base_time: u64) -> Self { + pub fn new(max_base_time: Duration) -> Self { let (sender, receiver) = mpsc::channel(100); let on_beat = OnBeat::new(); @@ -50,7 +50,7 @@ impl PaceMaker { ), current_view: current_height, current_high_qc_height: NodeHeight(0), - block_time: Duration::from_secs(max_base_time), + block_time: max_base_time, } }