core/connection/listeners: Create event on remove_listener (#2261)

Create a `ListenersEvent::Closed` when a listener is removed via
`Swarm::remove_listener`. This makes it more consistent with `Swarm::listen_on`,
and also informs the Swarm about the associated expired addresses.

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
Elena Frank
2021-10-11 22:38:55 +02:00
committed by GitHub
parent 3eb0344832
commit 7718d1de38
5 changed files with 77 additions and 14 deletions

View File

@ -324,8 +324,9 @@ where
/// Remove some listener.
///
/// Returns `Ok(())` if there was a listener with this ID.
pub fn remove_listener(&mut self, id: ListenerId) -> Result<(), ()> {
/// Returns `true` if there was a listener with this ID, `false`
/// otherwise.
pub fn remove_listener(&mut self, id: ListenerId) -> bool {
self.network.remove_listener(id)
}