Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
filter callback_cache while pull txs (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
rev-chaos authored and yejiayu committed Feb 10, 2020
1 parent b18c5b6 commit 2296852
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/mempool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ where
pub fn get_adapter(&self) -> &Adapter {
&self.adapter
}

fn show_unknown_txs(&self, tx_hashes: Vec<Hash>) -> Vec<Hash> {
self.tx_cache
.show_unknown(tx_hashes)
.into_iter()
.filter(|tx_hash| !self.callback_cache.contains_key(tx_hash))
.collect()
}
}

#[async_trait]
Expand Down Expand Up @@ -145,7 +153,7 @@ where
ctx: Context,
order_tx_hashes: Vec<Hash>,
) -> ProtocolResult<()> {
let unknown_hashes = self.tx_cache.show_unknown(order_tx_hashes);
let unknown_hashes = self.show_unknown_txs(order_tx_hashes);
if !unknown_hashes.is_empty() {
let unknown_len = unknown_hashes.len();
let txs = self.adapter.pull_txs(ctx.clone(), unknown_hashes).await?;
Expand All @@ -170,7 +178,7 @@ where
ctx: Context,
propose_tx_hashes: Vec<Hash>,
) -> ProtocolResult<()> {
let unknown_hashes = self.tx_cache.show_unknown(propose_tx_hashes);
let unknown_hashes = self.show_unknown_txs(propose_tx_hashes);
if !unknown_hashes.is_empty() {
let txs = self.adapter.pull_txs(ctx.clone(), unknown_hashes).await?;
txs.into_iter().for_each(|tx| {
Expand Down

0 comments on commit 2296852

Please sign in to comment.