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

Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Aug 15, 2024
1 parent 9ffbc3a commit 366c3f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tx-pool/src/component/verify_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Notify>,
ready_rx: Arc<Notify>,
/// 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`
Expand Down 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 366c3f5

Please sign in to comment.