Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Oct 27, 2023
1 parent 65bcfae commit 8b49def
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tx-pool/src/component/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ impl OrphanPool {
self.limit_size()
}

pub fn find_by_previous(&self, tx: &TransactionView) -> Vec<ProposalShortId> {
pub fn find_by_previous(&self, tx: &TransactionView) -> Vec<&ProposalShortId> {
tx.output_pts()
.iter()
.filter_map(|out_point| self.by_out_point.get(out_point).cloned())
.filter_map(|out_point| self.by_out_point.get(out_point))
.flatten()
.collect::<Vec<_>>()
}
Expand Down
10 changes: 5 additions & 5 deletions tx-pool/src/component/tests/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ fn test_orphan_duplicated() {

let txs = orphan.find_by_previous(&tx1);
assert_eq!(txs.len(), 3);
assert!(txs.contains(&tx2.proposal_short_id()));
assert!(txs.contains(&tx4.proposal_short_id()));
assert!(txs.contains(&tx5.proposal_short_id()));
assert!(txs.contains(&&tx2.proposal_short_id()));
assert!(txs.contains(&&tx4.proposal_short_id()));
assert!(txs.contains(&&tx5.proposal_short_id()));

orphan.remove_orphan_tx(&tx4.proposal_short_id());
let txs = orphan.find_by_previous(&tx1);
assert_eq!(txs.len(), 2);
assert!(txs.contains(&tx2.proposal_short_id()));
assert!(txs.contains(&tx5.proposal_short_id()));
assert!(txs.contains(&&tx2.proposal_short_id()));
assert!(txs.contains(&&tx5.proposal_short_id()));
}

0 comments on commit 8b49def

Please sign in to comment.