Skip to content

Commit

Permalink
feat: Restrart block streams with stale data
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Jul 17, 2024
1 parent d18289b commit 4b56891
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions coordinator/src/handlers/block_streams.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(test, allow(dead_code))]

use std::time::{Duration, SystemTime};

pub use block_streamer::StreamInfo;

use anyhow::Context;
Expand Down Expand Up @@ -241,10 +243,16 @@ impl BlockStreamsHandler {
block_stream: &StreamInfo,
) -> anyhow::Result<()> {
if let Some(health) = block_stream.health.as_ref() {
if !matches!(
let updated_at =
SystemTime::UNIX_EPOCH + Duration::from_secs(health.updated_at_timestamp_secs);

let stale = updated_at.elapsed().unwrap_or_default() > Duration::from_secs(30);
let stalled = matches!(
health.processing_state.try_into(),
Ok(ProcessingState::Stalled)
) {
);

if !stale && !stalled {
return Ok(());
}
}
Expand Down

0 comments on commit 4b56891

Please sign in to comment.