+ let mut header = match get_electrsd().client.block_headers_subscribe() {
+ Ok(header) => header,
+ Err(_) => {
+ // While subscribing should succeed the first time around, we ran into some cases where
+ // it didn't. Since we can't proceed without subscribing, we try again after a delay
+ // and panic if it still fails.
+ std::thread::sleep(Duration::from_secs(1));
+ get_electrsd().client.block_headers_subscribe().expect("failed to subscribe to block headers")
+ }
+ };
+