Skip to content

Commit

Permalink
update quorum_ticks to use interval (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Huang authored Feb 5, 2025
1 parent 0c4ccf9 commit 4d4d260
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lighthouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use structopt::StructOpt;
use tokio::sync::broadcast;
use tokio::sync::Mutex;
use tokio::task::JoinSet;
use tokio::time::sleep;
use tokio::time::interval;
use tonic::service::Routes;
use tonic::transport::server::TcpIncoming;
use tonic::transport::Server;
Expand Down Expand Up @@ -301,13 +301,11 @@ impl Lighthouse {
}

async fn _run_quorum(self: Arc<Self>) -> Result<()> {
let mut interval = interval(Duration::from_millis(self.opt.quorum_tick_ms));
loop {
{
let mut state = self.state.lock().await;
self.clone()._quorum_tick(&mut state)?;
}

sleep(Duration::from_millis(self.opt.quorum_tick_ms)).await;
interval.tick().await; // Wait for the next tick
let mut state = self.state.lock().await;
self.clone()._quorum_tick(&mut state)?;
}
}

Expand Down

0 comments on commit 4d4d260

Please sign in to comment.