Skip to content

Commit 4eac524

Browse files
committed
refactor: tweak loop a bit
1 parent 33a9d37 commit 4eac524

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/tasks/env.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ impl EnvTask {
6464
blocks.next().instrument(info_span!("EnvTask::task_fut::stream")).await
6565
{
6666
let Some(block) = blocks.last() else {
67-
// Clear the env, as the block has changed but we can't
68-
// get a new one
67+
// This case occurs when there are no changes to the block,
68+
// so we do nothing.
6969
debug!("empty filter changes");
70-
let _ = sender.send(None);
7170
continue;
7271
};
7372
let span = info_span!("EnvTask::task_fut::loop", hash = %block, number = tracing::field::Empty);
@@ -84,13 +83,16 @@ impl EnvTask {
8483
let _span = span.enter();
8584
let _ = sender.send(None);
8685
debug!("block not found");
86+
// This may mean the chain had a rollback, so the next poll
87+
// should find something.
8788
continue;
8889
}
8990
Err(err) => {
9091
let _span = span.enter();
9192
let _ = sender.send(None);
9293
error!(%err, "Failed to get latest block");
93-
break;
94+
// Error may be transient, so we should not break the loop.
95+
continue;
9496
}
9597
};
9698
span.record("number", previous.number);

0 commit comments

Comments
 (0)