Skip to content

Commit

Permalink
Fix bug in mixing time check (#45)
Browse files Browse the repository at this point in the history
Added some extra debugging as well.
  • Loading branch information
shamsasari authored Aug 21, 2024
1 parent 8314b16 commit 2ef23a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resolver = "2"
[workspace.package]
homepage = "https://projectglove.io/"
repository = "https://github.com/projectglove/glove-monorepo/"
version = "0.0.14"
version = "0.0.15"

[workspace.dependencies]
anyhow = "1.0.86"
Expand Down
1 change: 1 addition & 0 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub async fn calculate_mixing_time(
Ok(MixingTime::Deciding(decision_end - GLOVE_MIX_PERIOD))
}

#[derive(Debug)]
pub enum MixingTime {
Deciding(u32),
Confirming(u32),
Expand Down
9 changes: 6 additions & 3 deletions service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ async fn mark_voted_polls_as_final(
fn start_background_thread(context: Arc<GloveContext>, subscan: Subscan) {
spawn(async move {
loop {
debug!("Running background task...");
if let Err(error) = run_background_task(context.clone(), subscan.clone()).await {
warn!("Error from background task: {:?}", error)
}
Expand Down Expand Up @@ -377,13 +378,15 @@ async fn is_poll_ready_for_final_mix(
network: &SubstrateNetwork
) -> Result<bool, SubxtError> {
let now = network.current_block_number().await?;
match calculate_mixing_time(poll_status, network).await? {
MixingTime::Deciding(block_number) if block_number >= now => {
let mixing_time = calculate_mixing_time(poll_status, network).await?;
debug!("Mixing time for {} @ now={}: {:?}", poll_index, now, mixing_time);
match mixing_time {
MixingTime::Deciding(block_number) if now >= block_number => {
info!("Poll {} is nearing the end of its decision period and will be mixed",
poll_index);
Ok(true)
}
MixingTime::Confirming(block_number) if block_number >= now => {
MixingTime::Confirming(block_number) if now >= block_number => {
info!("Poll {} is nearing the end of its confirmation period and will be mixed",
poll_index);
Ok(true)
Expand Down

0 comments on commit 2ef23a7

Please sign in to comment.