File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ use structopt::StructOpt;
26
26
use tokio:: sync:: broadcast;
27
27
use tokio:: sync:: Mutex ;
28
28
use tokio:: task:: JoinSet ;
29
- use tokio:: time:: sleep ;
29
+ use tokio:: time:: interval ;
30
30
use tonic:: service:: Routes ;
31
31
use tonic:: transport:: server:: TcpIncoming ;
32
32
use tonic:: transport:: Server ;
@@ -301,13 +301,11 @@ impl Lighthouse {
301
301
}
302
302
303
303
async fn _run_quorum ( self : Arc < Self > ) -> Result < ( ) > {
304
+ let mut interval = interval ( Duration :: from_millis ( self . opt . quorum_tick_ms ) ) ;
304
305
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) ?;
311
309
}
312
310
}
313
311
You can’t perform that action at this time.
0 commit comments