mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 07:11:38 +00:00
Simplify handling of upgrade information. (#761)
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
//! The `Stream` component is used to poll the underlying transport, and the `Sink` component is
|
||||
//! used to send messages.
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use bytes::BytesMut;
|
||||
use futures::{future, sink, stream, Sink, Stream};
|
||||
use libp2p_core::{InboundUpgrade, Multiaddr, OutboundUpgrade, PeerId, UpgradeInfo};
|
||||
use multihash::Multihash;
|
||||
@ -136,12 +136,12 @@ impl Into<protobuf_structs::dht::Message_Peer> for KadPeer {
|
||||
pub struct KademliaProtocolConfig;
|
||||
|
||||
impl UpgradeInfo for KademliaProtocolConfig {
|
||||
type NamesIter = iter::Once<(Bytes, ())>;
|
||||
type UpgradeId = ();
|
||||
type Info = &'static [u8];
|
||||
type InfoIter = iter::Once<Self::Info>;
|
||||
|
||||
#[inline]
|
||||
fn protocol_names(&self) -> Self::NamesIter {
|
||||
iter::once(("/ipfs/kad/1.0.0".into(), ()))
|
||||
fn protocol_info(&self) -> Self::InfoIter {
|
||||
iter::once(b"/ipfs/kad/1.0.0")
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ where
|
||||
type Error = IoError;
|
||||
|
||||
#[inline]
|
||||
fn upgrade_inbound(self, incoming: C, _: ()) -> Self::Future {
|
||||
fn upgrade_inbound(self, incoming: C, _: Self::Info) -> Self::Future {
|
||||
future::ok(
|
||||
Framed::new(incoming, codec::UviBytes::default())
|
||||
.from_err::<IoError>()
|
||||
@ -180,7 +180,7 @@ where
|
||||
type Error = IoError;
|
||||
|
||||
#[inline]
|
||||
fn upgrade_outbound(self, incoming: C, _: ()) -> Self::Future {
|
||||
fn upgrade_outbound(self, incoming: C, _: Self::Info) -> Self::Future {
|
||||
future::ok(
|
||||
Framed::new(incoming, codec::UviBytes::default())
|
||||
.from_err::<IoError>()
|
||||
|
Reference in New Issue
Block a user