Skip to content

Commit

Permalink
cleanup find_conflict_tx
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Aug 11, 2023
1 parent 05e2f8a commit 07f4744
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 3 additions & 7 deletions tx-pool/src/component/pool_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,9 @@ impl PoolMap {
}

pub(crate) fn find_conflict_tx(&self, tx: &TransactionView) -> HashSet<ProposalShortId> {
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<ConflictEntry> {
Expand Down
6 changes: 2 additions & 4 deletions tx-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 07f4744

Please sign in to comment.