Skip to content

Commit

Permalink
VerifyQueue: Add re_notify method, re_notify other Workers before che…
Browse files Browse the repository at this point in the history
…ck tasks is not empty
  • Loading branch information
eval-exec committed Aug 15, 2024
1 parent 9ffbc3a commit eeb03f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tx-pool/src/component/verify_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions tx-pool/src/verify_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit eeb03f1

Please sign in to comment.