From 07f47445f106e5fb45677b89dcf9f1252a0cc54b Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 11 Aug 2023 21:56:21 +0800 Subject: [PATCH] cleanup find_conflict_tx --- tx-pool/src/component/pool_map.rs | 10 +++------- tx-pool/src/pool.rs | 6 ++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tx-pool/src/component/pool_map.rs b/tx-pool/src/component/pool_map.rs index edf1d2d0b30..acbf53858da 100644 --- a/tx-pool/src/component/pool_map.rs +++ b/tx-pool/src/component/pool_map.rs @@ -241,13 +241,9 @@ impl PoolMap { } pub(crate) fn find_conflict_tx(&self, tx: &TransactionView) -> HashSet { - let mut res = HashSet::default(); - for i in tx.input_pts_iter() { - if let Some(id) = self.edges.get_input_ref(&i) { - res.insert(id.clone()); - } - } - res + tx.input_pts_iter() + .filter_map(|out_point| self.edges.get_input_ref(&out_point).cloned()) + .collect() } pub(crate) fn resolve_conflict(&mut self, tx: &TransactionView) -> Vec { diff --git a/tx-pool/src/pool.rs b/tx-pool/src/pool.rs index 757b1c541ba..2125d814604 100644 --- a/tx-pool/src/pool.rs +++ b/tx-pool/src/pool.rs @@ -97,10 +97,8 @@ impl TxPool { if !self.enable_rbf() { return None; } - let conflicts = self.pool_map.find_conflict_tx(tx.transaction()); - // we don't allow conflicted Tx in pool now - assert!(conflicts.len() == 1); - self.calculate_min_replace_fee(&conflicts, tx.size) + let ids = vec![tx.proposal_short_id()].iter().cloned().collect(); + self.calculate_min_replace_fee(&ids, tx.size) } fn calculate_min_replace_fee(