From 366c3f530dd1936bc4c58dc603106e07c24dc10f Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 15 Aug 2024 19:02:07 +0800 Subject: [PATCH] VerifyQueue: Add re_notify method, re_notify other Workers before check tasks is not empty Signed-off-by: Eval EXEC --- tx-pool/src/component/verify_queue.rs | 7 ++++++- tx-pool/src/verify_mgr.rs | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tx-pool/src/component/verify_queue.rs b/tx-pool/src/component/verify_queue.rs index be0365d7d6..d770c19025 100644 --- a/tx-pool/src/component/verify_queue.rs +++ b/tx-pool/src/component/verify_queue.rs @@ -55,7 +55,7 @@ pub(crate) struct VerifyQueue { /// inner tx entry inner: MultiIndexVerifyEntryMap, /// subscribe this notify to get be notified when there is item in the queue - pub(crate) ready_rx: Arc, + ready_rx: Arc, /// total tx size in the queue, will reject new transaction if exceed the limit total_tx_size: usize, /// large cycle threshold, from `pool_config.max_tx_verify_cycles` @@ -186,6 +186,11 @@ impl VerifyQueue { Ok(true) } + /// When OnlySmallCycleTx Worker is wakeup, but found the tx is large cycle tx, notify other workers. + pub fn re_notify(&self) { + self.ready_rx.notify_one(); + } + /// Clears the map, removing all elements. pub fn clear(&mut self) { self.inner.clear(); diff --git a/tx-pool/src/verify_mgr.rs b/tx-pool/src/verify_mgr.rs index a964642912..1e0a9b5a70 100644 --- a/tx-pool/src/verify_mgr.rs +++ b/tx-pool/src/verify_mgr.rs @@ -90,11 +90,13 @@ impl Worker { match tasks.pop_front(self.role == WorkerRole::OnlySmallCycleTx) { Some(entry) => entry, None => { - tasks.ready_rx.notify_one(); - debug!( - "Worker (role: {:?}) queue is empty after pop_front, notify others now", + if !tasks.is_empty() { + tasks.re_notify(); + debug!( + "Worker (role: {:?}) didn't got tx after pop_front, but tasks is not empty, notify other Workers now", self.role ); + } return; } }