Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Oct 23, 2023
1 parent b4c38ad commit 1e8dbe4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tx-pool/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ impl TxPoolService {

pub(crate) async fn find_orphan_by_previous(&self, tx: &TransactionView) -> Vec<OrphanEntry> {
let orphan = self.orphan.read().await;
let ids = orphan.find_by_previous(tx);
ids.iter()
orphan
.find_by_previous(tx)
.iter()
.filter_map(|id| orphan.get(id).cloned())
.collect::<Vec<_>>()
}
Expand Down Expand Up @@ -920,24 +921,19 @@ impl TxPoolService {
}
}

self.remove_orphan_txs_by_attach(attached.iter()).await;
self.remove_orphan_txs_by_attach(&attached).await;
{
let mut chunk = self.chunk.write().await;
chunk.remove_chunk_txs(attached.iter().map(|tx| tx.proposal_short_id()));
}
}

async fn remove_orphan_txs_by_attach<'a>(
&self,
txs: impl Iterator<Item = &'a TransactionView>,
) {
let mut ids = vec![];
for tx in txs {
ids.push(tx.proposal_short_id());
async fn remove_orphan_txs_by_attach<'a>(&self, txs: &LinkedHashSet<TransactionView>) {
for tx in txs.iter() {
self.process_orphan_tx(tx).await;
}
let mut orphan = self.orphan.write().await;
orphan.remove_orphan_txs(ids.into_iter());
orphan.remove_orphan_txs(txs.iter().map(|tx| tx.proposal_short_id()));
}

fn readd_detached_tx(
Expand Down

0 comments on commit 1e8dbe4

Please sign in to comment.