From 14373ff80c4d2df5ffb4d313a7ee48c446fb30da Mon Sep 17 00:00:00 2001 From: FiveMovesAhead Date: Thu, 9 Jan 2025 11:25:43 +0800 Subject: [PATCH] Add delay before voting begins. --- tig-protocol/src/contracts/players.rs | 4 ++-- tig-structs/src/config.rs | 1 + tig-structs/src/core.rs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tig-protocol/src/contracts/players.rs b/tig-protocol/src/contracts/players.rs index 652d1e3..7991a8c 100644 --- a/tig-protocol/src/contracts/players.rs +++ b/tig-protocol/src/contracts/players.rs @@ -212,8 +212,8 @@ pub async fn set_vote( .get_breakthrough_state(&breakthrough_id) .await .ok_or_else(|| anyhow!("Invalid breakthrough '{}'", breakthrough_id))?; - if breakthrough_state.round_pushed > latest_block_details.round - && latest_block_details.round >= breakthrough_state.round_votes_tallied + if latest_block_details.round < breakthrough_state.round_voting_starts + || latest_block_details.round >= breakthrough_state.round_votes_tallied { return Err(anyhow!("Cannot vote on breakthrough '{}'", breakthrough_id)); } diff --git a/tig-structs/src/config.rs b/tig-structs/src/config.rs index 4da83da..2c82563 100644 --- a/tig-structs/src/config.rs +++ b/tig-structs/src/config.rs @@ -23,6 +23,7 @@ serializable_struct_with_getters! { BreakthroughsConfig { bootstrap_address: String, min_percent_yes_votes: f64, + vote_start_delay: u32, vote_period: u32, min_lock_period_to_vote: u32, submission_fee: PreciseNumber, diff --git a/tig-structs/src/core.rs b/tig-structs/src/core.rs index 6b88564..553972c 100644 --- a/tig-structs/src/core.rs +++ b/tig-structs/src/core.rs @@ -272,6 +272,7 @@ serializable_struct_with_getters! { block_confirmed: u32, round_submitted: u32, round_pushed: u32, + round_voting_starts: u32, round_votes_tallied: u32, votes_tally: HashMap, round_active: Option,