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 bc7e613
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
5 changes: 2 additions & 3 deletions test/src/specs/tx_pool/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ impl Spec for RbfOnlyForResolveDead {

let tx_hash_0 = node0.generate_transaction();

let tx1 = node0.new_transaction(tx_hash_0.clone());
let tx1_clone = tx1.clone();
let tx1 = node0.new_transaction(tx_hash_0);

// This is an unknown input
let tx_hash_1 = Byte32::zero();
let tx2 = tx1_clone
let tx2 = tx1
.as_advanced_builder()
.set_inputs(vec![{
CellInput::new_builder()
Expand Down
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 bc7e613

Please sign in to comment.