mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-30 18:21:33 +00:00
Remove ConnectionInfo trait (#1813)
In all cases, we pass the PeerId directly as the connection info. The flexbility of doing something different here was originally envisioned but turned out to be never needed. For reference see: https://github.com/libp2p/rust-libp2p/issues/1798#issuecomment-714526056 Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -159,37 +159,11 @@ impl ConnectedPoint {
|
||||
|
||||
/// Information about a successfully established connection.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Connected<I> {
|
||||
pub struct Connected {
|
||||
/// The connected endpoint, including network address information.
|
||||
pub endpoint: ConnectedPoint,
|
||||
/// Information obtained from the transport.
|
||||
pub info: I,
|
||||
}
|
||||
|
||||
impl<I> Connected<I>
|
||||
where
|
||||
I: ConnectionInfo
|
||||
{
|
||||
pub fn peer_id(&self) -> &I::PeerId {
|
||||
self.info.peer_id()
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a connection.
|
||||
pub trait ConnectionInfo {
|
||||
/// Identity of the node we are connected to.
|
||||
type PeerId: Eq + Hash;
|
||||
|
||||
/// Returns the identity of the node we are connected to on this connection.
|
||||
fn peer_id(&self) -> &Self::PeerId;
|
||||
}
|
||||
|
||||
impl ConnectionInfo for PeerId {
|
||||
type PeerId = PeerId;
|
||||
|
||||
fn peer_id(&self) -> &PeerId {
|
||||
self
|
||||
}
|
||||
pub peer_id: PeerId,
|
||||
}
|
||||
|
||||
/// Event generated by a [`Connection`].
|
||||
@ -334,12 +308,12 @@ impl<'a> IncomingInfo<'a> {
|
||||
|
||||
/// Borrowed information about an outgoing connection currently being negotiated.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct OutgoingInfo<'a, TPeerId> {
|
||||
pub struct OutgoingInfo<'a> {
|
||||
pub address: &'a Multiaddr,
|
||||
pub peer_id: Option<&'a TPeerId>,
|
||||
pub peer_id: Option<&'a PeerId>,
|
||||
}
|
||||
|
||||
impl<'a, TPeerId> OutgoingInfo<'a, TPeerId> {
|
||||
impl<'a> OutgoingInfo<'a> {
|
||||
/// Builds a `ConnectedPoint` corresponding to the outgoing connection.
|
||||
pub fn to_connected_point(&self) -> ConnectedPoint {
|
||||
ConnectedPoint::Dialer {
|
||||
|
Reference in New Issue
Block a user