Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VerifyQueue: re_notify other Worker when OnlySmallCycleTx received a large cycle tx #4591

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 17 additions & 9 deletions tx-pool/src/verify_mgr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate num_cpus;
use crate::component::verify_queue::VerifyQueue;
use crate::service::TxPoolService;
use ckb_logger::info;
use ckb_logger::{debug, info};
use ckb_script::ChunkCommand;
use ckb_stop_handler::CancellationToken;
use std::sync::Arc;
Expand Down Expand Up @@ -83,15 +83,23 @@ impl Worker {
if self.tasks.read().await.is_empty() {
return;
}

// pick a entry to run verify
let entry = match self
.tasks
.write()
.await
.pop_front(self.role == WorkerRole::OnlySmallCycleTx)
{
Some(entry) => entry,
None => return,
let entry = {
let mut tasks = self.tasks.write().await;
match tasks.pop_front(self.role == WorkerRole::OnlySmallCycleTx) {
Some(entry) => entry,
None => {
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
);
chenyukang marked this conversation as resolved.
Show resolved Hide resolved
}
return;
}
}
};

if let Some((res, snapshot)) = self
Expand Down
Loading