mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 00:41:59 +00:00
refactor: expose and use THandlerOutEvent
type alias (#3368)
Previously, we used the full reference to the `OutEvent` of the `ConnectionHandler` in all implementations of `NetworkBehaviour`. Not only is this very verbose, it is also more brittle to changes. With the current implementation plan for #2824, we will be removing the `IntoConnectionHandler` abstraction. Using a type-alias to refer to the `OutEvent` makes the migration much easier.
This commit is contained in:
@@ -50,6 +50,7 @@ pub use handler::{Config, Failure, Success};
|
||||
use libp2p_core::PeerId;
|
||||
use libp2p_swarm::{
|
||||
behaviour::FromSwarm, ConnectionId, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
THandlerOutEvent,
|
||||
};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
@@ -123,7 +124,12 @@ impl NetworkBehaviour for Behaviour {
|
||||
Handler::new(self.config.clone())
|
||||
}
|
||||
|
||||
fn on_connection_handler_event(&mut self, peer: PeerId, _: ConnectionId, result: Result) {
|
||||
fn on_connection_handler_event(
|
||||
&mut self,
|
||||
peer: PeerId,
|
||||
_: ConnectionId,
|
||||
result: THandlerOutEvent<Self>,
|
||||
) {
|
||||
self.events.push_front(Event { peer, result })
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user