From eeb03f1bf74ee4e15369d401eccae8151f4e2163 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 --- tx-pool/src/component/verify_queue.rs | 5 +++++ tx-pool/src/verify_mgr.rs | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tx-pool/src/component/verify_queue.rs b/tx-pool/src/component/verify_queue.rs index be0365d7d6..608e2ac3d5 100644 --- a/tx-pool/src/component/verify_queue.rs +++ b/tx-pool/src/component/verify_queue.rs @@ -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; } }