From b0b48ce5d58b58b4df892efd85111cb23b2a814d Mon Sep 17 00:00:00 2001 From: max143672 Date: Thu, 24 Aug 2023 17:24:17 +0400 Subject: [PATCH] Refactor notification_root usage in ibd/flow.rs This commit removes a redundant `take().unwrap()` of the `notification_root` field and the subsequent reassignment of it. Now the field is directly accessed via `as_ref().unwrap()`. This change removes unnecessary operations, and might slightly improve performance. --- protocol/flows/src/v5/ibd/flow.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/flows/src/v5/ibd/flow.rs b/protocol/flows/src/v5/ibd/flow.rs index f4c1687ec..811aa4ea9 100644 --- a/protocol/flows/src/v5/ibd/flow.rs +++ b/protocol/flows/src/v5/ibd/flow.rs @@ -320,13 +320,14 @@ impl IbdFlow { relay_block: &Block, ) -> Result<(), ProtocolError> { let highest_shared_header_score = consensus.async_get_header(highest_known_syncer_chain_hash).await?.daa_score; - let notification_root = self.notification_root.take().unwrap(); let mut progress_reporter = ProgressReporter::new( highest_shared_header_score, relay_block.header.daa_score, "block headers", Some(|headers: usize, progress: i32| { - notification_root + self.notification_root + .as_ref() + .unwrap() .notify(Notification::SyncStateChanged(SyncStateChangedNotification::new_headers(headers as u64, progress as i64))) .expect("expecting an open unbounded channel") }), @@ -363,7 +364,6 @@ impl IbdFlow { let prev_chunk_len = prev_jobs.len(); try_join_all(prev_jobs).await?; progress_reporter.report_completion(prev_chunk_len); - self.notification_root = Some(notification_root); } self.sync_missing_relay_past_headers(consensus, syncer_virtual_selected_parent, relay_block.hash()).await?;