Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in mixing time check #45

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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