handle empty futures

This commit is contained in:
Bryan Stitt 2023-10-12 20:48:37 -07:00
parent eaaf9bdc81
commit 51d86ade59
2 changed files with 17 additions and 5 deletions

@ -743,7 +743,7 @@ in another repo: event subscriber
- [ ] have an upgrade tier that queries multiple backends at once. returns on first Ok result, collects errors. if no Ok, find the most common error and then respond with that
- [ ] give public_recent_ips_salt a better, more general, name
- [ ] include tier in the head block logs?
- [ ] i think i use FuturesUnordered when a try_join_all might be better
- [x] i think i use FuturesUnordered when a try_join_all might be better
- [ ] since we are read-heavy on our configs, maybe we should use a cache
- "using a thread local storage and explicit types" https://docs.rs/arc-swap/latest/arc_swap/cache/struct.Cache.html
- [ ] tests for config reloading

@ -853,11 +853,23 @@ impl Web3Rpc {
}
}
// exit if any of the futures exit
// TODO: have an enum for which one exited?
let (first_exit, _, _) = select_all(futures).await;
if futures.is_empty() {
// we didn't have anything to subscribe to. what should happen?
let clone = self.clone();
debug!(?first_exit, "subscriptions on {} exited", self);
loop {
sleep(Duration::from_secs(60)).await;
if self.should_disconnect() {
break;
}
}
} else {
// exit if any of the futures exit
// TODO: have an enum for which one exited?
let (first_exit, _, _) = select_all(futures).await;
debug!(?first_exit, "subscriptions on {} exited", self);
}
// clear the head block
if let Some(block_and_rpc_sender) = block_and_rpc_sender {