mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 15:21:33 +00:00
Add NetworkBehaviour::inject_replaced (#914)
* Add NetworkBehaviour::inject_replaced * Address style * Forgot to call set_disconnected * Also add incoming addresses to kbuckets
This commit is contained in:
@ -262,8 +262,7 @@ where TBehaviour: NetworkBehaviour,
|
||||
self.behaviour.inject_disconnected(&peer_id, endpoint);
|
||||
},
|
||||
Async::Ready(RawSwarmEvent::Replaced { peer_id, closed_endpoint, endpoint }) => {
|
||||
self.behaviour.inject_disconnected(&peer_id, closed_endpoint);
|
||||
self.behaviour.inject_connected(peer_id, endpoint);
|
||||
self.behaviour.inject_replaced(peer_id, closed_endpoint, endpoint);
|
||||
},
|
||||
Async::Ready(RawSwarmEvent::IncomingConnection(incoming)) => {
|
||||
let handler = self.behaviour.new_handler();
|
||||
@ -343,6 +342,12 @@ pub trait NetworkBehaviour {
|
||||
/// endpoint is the one we used to be connected to.
|
||||
fn inject_disconnected(&mut self, peer_id: &PeerId, endpoint: ConnectedPoint);
|
||||
|
||||
/// Indicates the behaviour that we replace the connection from the node with another.
|
||||
fn inject_replaced(&mut self, peer_id: PeerId, closed_endpoint: ConnectedPoint, new_endpoint: ConnectedPoint) {
|
||||
self.inject_disconnected(&peer_id, closed_endpoint);
|
||||
self.inject_connected(peer_id, new_endpoint);
|
||||
}
|
||||
|
||||
/// Indicates the behaviour that the node with the given peer id has generated an event for
|
||||
/// us.
|
||||
///
|
||||
|
Reference in New Issue
Block a user