Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions linera-client/src/chain_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,13 @@ impl<C: ClientContext + 'static> ChainListener<C> {
Some(cancellation_token)
}

fn remove_event_subscriber(&mut self, chain_id: ChainId) {
self.event_subscribers.retain(|_, subscribers| {
subscribers.remove(&chain_id);
!subscribers.is_empty()
});
}

/// Updates the event subscribers map, and returns all publishing chains we need to listen to.
async fn update_event_subscriptions(
&mut self,
Expand Down Expand Up @@ -608,6 +615,7 @@ impl<C: ClientContext + 'static> ChainListener<C> {
error!(%chain_id, "attempted to drop a non-existent listener");
continue;
};
self.remove_event_subscriber(chain_id);
listening_client.stop().await;
if let Err(error) = self.context.lock().await.wallet().remove(chain_id).await {
error!(%error, %chain_id, "error removing a chain from the wallet");
Expand Down Expand Up @@ -638,6 +646,7 @@ impl<C: ClientContext + 'static> ChainListener<C> {
error!(%chain_id, "attempted to drop a non-existent listener");
continue;
};
self.remove_event_subscriber(chain_id);
listening_client.stop().await;
continue;
};
Expand Down
Loading