@@ -13,24 +13,24 @@ use crate::{
1313} ;
1414use diesel:: { BoolExpressionMethods , ExpressionMethods , QueryDsl , RunQueryDsl } ;
1515use std:: { path:: PathBuf , sync:: Arc } ;
16+ use tokio:: sync:: Mutex ;
1617use tracing:: { error, info, warn} ;
1718
1819pub ( super ) struct PulseRunner {
1920 webhooks : Arc < WebhookManager > ,
2021 settings : Arc < Settings > ,
2122 pool : Arc < DbPool > ,
23+
24+ anchors_available : Arc < Mutex < bool > > ,
2225}
2326
2427impl PulseRunner {
25- pub const fn new (
26- settings : Arc < Settings > ,
27- pool : Arc < DbPool > ,
28- webhooks : Arc < WebhookManager > ,
29- ) -> Self {
28+ pub fn new ( settings : Arc < Settings > , pool : Arc < DbPool > , webhooks : Arc < WebhookManager > ) -> Self {
3029 Self {
3130 webhooks,
3231 settings,
3332 pool,
33+ anchors_available : Arc :: new ( Mutex :: new ( true ) ) ,
3434 }
3535 }
3636
@@ -268,6 +268,24 @@ impl PulseRunner {
268268 }
269269
270270 pub async fn run ( & self ) -> anyhow:: Result < ( ) > {
271+ let set_anchors_available = self . settings . anchors . iter ( ) . all ( |anchor| anchor. exists ( ) ) ;
272+
273+ let mut anchors_available = self . anchors_available . lock ( ) . await ;
274+ if set_anchors_available != * anchors_available {
275+ if set_anchors_available {
276+ info ! ( "anchors are available again, continuing" ) ;
277+ } else {
278+ warn ! ( "anchors are not available, pausing" ) ;
279+ }
280+ * anchors_available = set_anchors_available;
281+ }
282+
283+ if !* anchors_available {
284+ return Ok ( ( ) ) ;
285+ }
286+
287+ drop ( anchors_available) ;
288+
271289 self . update_found_status ( ) . await ?;
272290 self . update_process_status ( ) . await ?;
273291 self . cleanup ( ) . await ?;
0 commit comments