From 89531c3aaf31450a666f4f009e782560febf0c22 Mon Sep 17 00:00:00 2001 From: yukang Date: Mon, 23 Oct 2023 10:50:21 +0800 Subject: [PATCH] add comments --- tx-pool/src/process.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tx-pool/src/process.rs b/tx-pool/src/process.rs index 80ff1262c62..61d303b0990 100644 --- a/tx-pool/src/process.rs +++ b/tx-pool/src/process.rs @@ -475,7 +475,7 @@ impl TxPoolService { let orphan = self.orphan.read().await; let ids = orphan.find_by_previous(tx); ids.iter() - .map(|id| orphan.get(id).cloned().unwrap()) + .filter_map(|id| orphan.get(id).cloned()) .collect::>() } @@ -483,6 +483,9 @@ impl TxPoolService { self.orphan.write().await.remove_orphan_tx(id); } + /// Remove all orphans which are resolved by the given transaction + /// the process is like a breath first search, if there is a cycle in `orphan_queue`, + /// `_process_tx` will return `Reject` since we have checked duplicated tx pub(crate) async fn process_orphan_tx(&self, tx: &TransactionView) { let mut orphan_queue: VecDeque = VecDeque::new(); orphan_queue.push_back(tx.clone());