swarm: Extend NetworkBehaviour callbacks. (#2011)

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
David Craven
2021-03-24 17:21:53 +01:00
committed by GitHub
parent be2fb4ea8a
commit 7779b8e2c1
9 changed files with 155 additions and 49 deletions

View File

@ -147,17 +147,17 @@ pub trait NetworkBehaviour: Send + 'static {
fn inject_dial_failure(&mut self, _peer_id: &PeerId) {
}
/// Indicates to the behaviour that a new listener was created.
fn inject_new_listener(&mut self, _id: ListenerId) {
}
/// Indicates to the behaviour that we have started listening on a new multiaddr.
fn inject_new_listen_addr(&mut self, _addr: &Multiaddr) {
fn inject_new_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
}
/// Indicates to the behaviour that a new multiaddr we were listening on has expired,
/// Indicates to the behaviour that a multiaddr we were listening on has expired,
/// which means that we are no longer listening in it.
fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr) {
}
/// Indicates to the behaviour that we have discovered a new external address for us.
fn inject_new_external_addr(&mut self, _addr: &Multiaddr) {
fn inject_expired_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
}
/// A listener experienced an error.
@ -168,6 +168,14 @@ pub trait NetworkBehaviour: Send + 'static {
fn inject_listener_closed(&mut self, _id: ListenerId, _reason: Result<(), &std::io::Error>) {
}
/// Indicates to the behaviour that we have discovered a new external address for us.
fn inject_new_external_addr(&mut self, _addr: &Multiaddr) {
}
/// Indicates to the behaviour that an external address was removed.
fn inject_expired_external_addr(&mut self, _addr: &Multiaddr) {
}
/// Polls for things that swarm should do.
///
/// This API mimics the API of the `Stream` trait. The method may register the current task in