From 7cc8283ce0935367d64a5fe5b68714d0f7e6deb2 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 12 May 2020 10:50:30 +0300 Subject: [PATCH] get tx_hashes from watcher --- client/transaction-pool/graph/src/listener.rs | 9 +++++---- client/transaction-pool/graph/src/validated_pool.rs | 10 +--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs index 92ba71007e209..602c75e099814 100644 --- a/client/transaction-pool/graph/src/listener.rs +++ b/client/transaction-pool/graph/src/listener.rs @@ -129,10 +129,11 @@ impl Listener { } /// Notify all watchers that transactions have been finalized - pub fn finalized(&mut self, block_hash: BlockHash, txs: Vec) { - self.finality_watchers.remove(&block_hash); - for h in txs { - self.fire(&h, |s| s.finalized(block_hash.clone())) + pub fn finalized(&mut self, block_hash: BlockHash) { + if let Some(hashes) = self.finality_watchers.remove(&block_hash) { + for hash in hashes { + self.fire(&hash, |s| s.finalized(block_hash)) + } } } } diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index 2ff2acfe24fc8..19f491bb1d383 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -559,15 +559,7 @@ impl ValidatedPool { /// Notify all watchers that transactions in the block with hash have been finalized pub async fn on_block_finalized(&self, block_hash: BlockHash) -> Result<(), B::Error> { debug!(target: "txpool", "Attempting to notify watchers of finalization for {}", block_hash); - // fetch all extrinsic hashes - if let Some(txs) = self.api.block_body(&BlockId::Hash(block_hash.clone())).await? { - let tx_hashes = txs.into_iter() - .map(|tx| self.api.hash_and_length(&tx).0) - .collect::>(); - // notify the watcher that these extrinsics have been finalized - self.listener.write().finalized(block_hash, tx_hashes); - } - + self.listener.write().finalized(block_hash); Ok(()) }