Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(torii-core): log when engine syncing has been reestablished #2301

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@

let mut shutdown_rx = self.shutdown_tx.subscribe();

let mut erroring_out = false;

Check warning on line 97 in crates/torii/core/src/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/engine.rs#L97

Added line #L97 was not covered by tests
loop {
tokio::select! {
_ = shutdown_rx.recv() => {
Expand All @@ -102,11 +103,17 @@
_ = async {
match self.sync_to_head(head, pending_block_tx).await {
Ok((latest_block_number, latest_pending_tx)) => {
if erroring_out {
erroring_out = false;
backoff_delay = Duration::from_secs(1);
info!(target: LOG_TARGET, latest_block_number = latest_block_number, "Syncing reestablished.");
}

Check warning on line 110 in crates/torii/core/src/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/engine.rs#L106-L110

Added lines #L106 - L110 were not covered by tests

pending_block_tx = latest_pending_tx;
head = latest_block_number;
backoff_delay = Duration::from_secs(1);
}
Err(e) => {
erroring_out = true;

Check warning on line 116 in crates/torii/core/src/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/core/src/engine.rs#L116

Added line #L116 was not covered by tests
error!(target: LOG_TARGET, error = %e, "Syncing to head.");
sleep(backoff_delay).await;
if backoff_delay < max_backoff_delay {
Expand Down
Loading