File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ use structopt::StructOpt;
2626use tokio:: sync:: broadcast;
2727use tokio:: sync:: Mutex ;
2828use tokio:: task:: JoinSet ;
29- use tokio:: time:: sleep ;
29+ use tokio:: time:: interval ;
3030use tonic:: service:: Routes ;
3131use tonic:: transport:: server:: TcpIncoming ;
3232use tonic:: transport:: Server ;
@@ -301,13 +301,11 @@ impl Lighthouse {
301301 }
302302
303303 async fn _run_quorum ( self : Arc < Self > ) -> Result < ( ) > {
304+ let mut interval = interval ( Duration :: from_millis ( self . opt . quorum_tick_ms ) ) ;
304305 loop {
305- {
306- let mut state = self . state . lock ( ) . await ;
307- self . clone ( ) . _quorum_tick ( & mut state) ?;
308- }
309-
310- sleep ( Duration :: from_millis ( self . opt . quorum_tick_ms ) ) . await ;
306+ interval. tick ( ) . await ; // Wait for the next tick
307+ let mut state = self . state . lock ( ) . await ;
308+ self . clone ( ) . _quorum_tick ( & mut state) ?;
311309 }
312310 }
313311
You can’t perform that action at this time.
0 commit comments