Skip to content

Commit

Permalink
Merge branch 'develop' into yukang-fix-script-test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang authored Aug 15, 2024
2 parents 7af44ce + 3c9409e commit 282b04c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
9 changes: 6 additions & 3 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ impl Node {
status,
self.log_path().display()
);
info!("Last 200 lines of log:");
info!("Last 500 lines of log:");
self.print_last_500_lines_log(&self.log_path());
info!("End of last 200 lines of log");
info!("End of last 500 lines of log");
// parent process will exit
return;
}
Expand All @@ -693,6 +693,9 @@ impl Node {
error,
self.log_path().display()
);
info!("Last 500 lines of log:");
self.print_last_500_lines_log(&self.log_path());
info!("End of last 500 lines of log");
return;
}
}
Expand All @@ -708,7 +711,7 @@ impl Node {
self.set_node_id(node_info.node_id.as_str());
}

fn print_last_500_lines_log(&self, log_file: &Path) {
pub(crate) fn print_last_500_lines_log(&self, log_file: &Path) {
let file = File::open(log_file).expect("open log file");
let reader = BufReader::new(file);
let lines: Vec<String> = reader.lines().map(|line| line.unwrap()).collect();
Expand Down
5 changes: 5 additions & 0 deletions test/src/specs/tx_pool/send_large_cycles_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ impl Spec for SendLargeCyclesTxToRelay {
.transaction
.is_some()
});
if !result {
info!("node0 last 500 log begin");
node0.print_last_500_lines_log(&node0.log_path());
info!("node0 last 500 log end");
}
assert!(result, "Node0 should accept tx");
}

Expand Down
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
);
}
return;
}
}
};

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

0 comments on commit 282b04c

Please sign in to comment.