Skip to content

Commit

Permalink
Instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Sep 7, 2023
1 parent e9cdff5 commit 221b8ca
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/task_monitor/tasks/finalize_identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,7 @@ async fn finalize_roots_loop(
}
}

async fn finalize_roots(
database: &Database,
identity_manager: &IdentityManager,
finalized_tree: &TreeVersion<Canonical>,
all_roots: Vec<U256>,
) -> Result<(), anyhow::Error> {
Ok(for root in all_roots {
info!(?root, "Finalizing root");

let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?;

if is_root_finalized {
finalized_tree.apply_updates_up_to(root.into());
database.mark_root_as_mined(&root.into()).await?;

info!(?root, "Root finalized");
}
})
}

#[instrument(level = "info", skip_all)]
async fn fetch_logs<A, B>(
mainnet_scanner: &mut BlockScanner<A>,
secondary_scanners: &mut HashMap<Address, BlockScanner<B>>,
Expand Down Expand Up @@ -155,6 +136,27 @@ where
Ok(all_roots)
}

#[instrument(level = "info", skip_all)]
async fn finalize_roots(
database: &Database,
identity_manager: &IdentityManager,
finalized_tree: &TreeVersion<Canonical>,
all_roots: Vec<U256>,
) -> Result<(), anyhow::Error> {
Ok(for root in all_roots {
info!(?root, "Finalizing root");

let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?;

if is_root_finalized {
finalized_tree.apply_updates_up_to(root.into());
database.mark_root_as_mined(&root.into()).await?;

info!(?root, "Root finalized");
}
})

Check warning on line 157 in src/task_monitor/tasks/finalize_identities.rs

View workflow job for this annotation

GitHub Actions / clippy

passing a unit value to a function

warning: passing a unit value to a function --> src/task_monitor/tasks/finalize_identities.rs:146:5 | 146 | / Ok(for root in all_roots { 147 | | info!(?root, "Finalizing root"); 148 | | 149 | | let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; ... | 156 | | } 157 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg note: the lint level is defined here --> src/lib.rs:2:9 | 2 | #![warn(clippy::all, clippy::pedantic, clippy::cargo)] | ^^^^^^^^^^^ = note: `#[warn(clippy::unit_arg)]` implied by `#[warn(clippy::all)]` help: move the expression in front of the call and replace it with the unit literal `()` | 146 ~ for root in all_roots { 147 + info!(?root, "Finalizing root"); 148 + 149 + let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; 150 + 151 + if is_root_finalized { 152 + finalized_tree.apply_updates_up_to(root.into()); 153 + database.mark_root_as_mined(&root.into()).await?; 154 + 155 + info!(?root, "Root finalized"); 156 + } 157 + }; 158 + Ok(()) |

Check warning on line 157 in src/task_monitor/tasks/finalize_identities.rs

View workflow job for this annotation

GitHub Actions / clippy

passing a unit value to a function

warning: passing a unit value to a function --> src/task_monitor/tasks/finalize_identities.rs:146:5 | 146 | / Ok(for root in all_roots { 147 | | info!(?root, "Finalizing root"); 148 | | 149 | | let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; ... | 156 | | } 157 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg note: the lint level is defined here --> src/lib.rs:2:9 | 2 | #![warn(clippy::all, clippy::pedantic, clippy::cargo)] | ^^^^^^^^^^^ = note: `#[warn(clippy::unit_arg)]` implied by `#[warn(clippy::all)]` help: move the expression in front of the call and replace it with the unit literal `()` | 146 ~ for root in all_roots { 147 + info!(?root, "Finalizing root"); 148 + 149 + let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; 150 + 151 + if is_root_finalized { 152 + finalized_tree.apply_updates_up_to(root.into()); 153 + database.mark_root_as_mined(&root.into()).await?; 154 + 155 + info!(?root, "Root finalized"); 156 + } 157 + }; 158 + Ok(()) |

Check warning on line 157 in src/task_monitor/tasks/finalize_identities.rs

View workflow job for this annotation

GitHub Actions / clippy

passing a unit value to a function

warning: passing a unit value to a function --> src/task_monitor/tasks/finalize_identities.rs:146:5 | 146 | / Ok(for root in all_roots { 147 | | info!(?root, "Finalizing root"); 148 | | 149 | | let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; ... | 156 | | } 157 | | }) | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg note: the lint level is defined here --> src/lib.rs:2:9 | 2 | #![warn(clippy::all, clippy::pedantic, clippy::cargo)] | ^^^^^^^^^^^ = note: `#[warn(clippy::unit_arg)]` implied by `#[warn(clippy::all)]` help: move the expression in front of the call and replace it with the unit literal `()` | 146 ~ for root in all_roots { 147 + info!(?root, "Finalizing root"); 148 + 149 + let is_root_finalized = identity_manager.is_root_mined_multi_chain(root).await?; 150 + 151 + if is_root_finalized { 152 + finalized_tree.apply_updates_up_to(root.into()); 153 + database.mark_root_as_mined(&root.into()).await?; 154 + 155 + info!(?root, "Root finalized"); 156 + } 157 + }; 158 + Ok(()) |
}

async fn init_secondary_scanners<T>(
providers: &[BridgedWorldId<T>],
scanning_window_size: u64,
Expand Down

0 comments on commit 221b8ca

Please sign in to comment.