From 95ab35963444ec2f2c175b0472eb0e02c41e2faf Mon Sep 17 00:00:00 2001 From: quake Date: Tue, 26 Dec 2023 14:04:50 +0900 Subject: [PATCH] chore: optimize block assembler notify fn --- tx-pool/src/block_assembler/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tx-pool/src/block_assembler/mod.rs b/tx-pool/src/block_assembler/mod.rs index a21319fc5c..381a263790 100644 --- a/tx-pool/src/block_assembler/mod.rs +++ b/tx-pool/src/block_assembler/mod.rs @@ -632,6 +632,9 @@ impl BlockAssembler { } pub(crate) async fn notify(&self) { + if !self.need_to_notify() { + return; + } let template = self.get_current().await; if let Ok(template_json) = serde_json::to_string(&template) { let notify_timeout = Duration::from_millis(self.config.notify_timeout_millis); @@ -687,6 +690,10 @@ impl BlockAssembler { } } } + + fn need_to_notify(&self) -> bool { + !self.config.notify.is_empty() || !self.config.notify_scripts.is_empty() + } } #[derive(Clone)]