mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-21 05:41:33 +00:00
Simplify handling of upgrade information. (#761)
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use crate::rpc_proto;
|
||||
use futures::future;
|
||||
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, PeerId};
|
||||
@ -42,12 +42,12 @@ impl FloodsubConfig {
|
||||
}
|
||||
|
||||
impl UpgradeInfo for FloodsubConfig {
|
||||
type UpgradeId = ();
|
||||
type NamesIter = iter::Once<(Bytes, Self::UpgradeId)>;
|
||||
type Info = &'static [u8];
|
||||
type InfoIter = iter::Once<Self::Info>;
|
||||
|
||||
#[inline]
|
||||
fn protocol_names(&self) -> Self::NamesIter {
|
||||
iter::once(("/floodsub/1.0.0".into(), ()))
|
||||
fn protocol_info(&self) -> Self::InfoIter {
|
||||
iter::once(b"/floodsub/1.0.0")
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ where
|
||||
type Future = future::FutureResult<Self::Output, Self::Error>;
|
||||
|
||||
#[inline]
|
||||
fn upgrade_inbound(self, socket: TSocket, _: Self::UpgradeId) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
future::ok(Framed::new(socket, FloodsubCodec { length_prefix: Default::default() }))
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ where
|
||||
type Future = future::FutureResult<Self::Output, Self::Error>;
|
||||
|
||||
#[inline]
|
||||
fn upgrade_outbound(self, socket: TSocket, _: Self::UpgradeId) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
future::ok(Framed::new(socket, FloodsubCodec { length_prefix: Default::default() }))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user