Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
get tx_hashes from watcher (#5981)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored May 12, 2020
1 parent d2b38b6 commit ba00ef1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 5 additions & 4 deletions client/transaction-pool/graph/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ impl<H: hash::Hash + traits::Member + Serialize, C: ChainApi> Listener<H, C> {
}

/// Notify all watchers that transactions have been finalized
pub fn finalized(&mut self, block_hash: BlockHash<C>, txs: Vec<H>) {
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<C>) {
if let Some(hashes) = self.finality_watchers.remove(&block_hash) {
for hash in hashes {
self.fire(&hash, |s| s.finalized(block_hash))
}
}
}
}
10 changes: 1 addition & 9 deletions client/transaction-pool/graph/src/validated_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,7 @@ impl<B: ChainApi> ValidatedPool<B> {
/// Notify all watchers that transactions in the block with hash have been finalized
pub async fn on_block_finalized(&self, block_hash: BlockHash<B>) -> 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::<Vec<_>>();
// notify the watcher that these extrinsics have been finalized
self.listener.write().finalized(block_hash, tx_hashes);
}

self.listener.write().finalized(block_hash);
Ok(())
}

Expand Down

0 comments on commit ba00ef1

Please sign in to comment.