Skip to content

Commit

Permalink
Fix use of deprecated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh committed Aug 8, 2023
1 parent 7b2e8a3 commit ab28cd0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/discovery/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use discv5::{Discv5, Discv5ConfigBuilder, Discv5Event, Enr, QueryError};
use futures::stream::FuturesUnordered;
use futures::{Future, FutureExt, StreamExt};
use libp2p::core::Endpoint;
use libp2p::swarm::dummy::{ConnectionHandler as DummyConnectionHandler, ConnectionHandler};
use libp2p::swarm::dummy::ConnectionHandler as DummyConnectionHandler;
use libp2p::swarm::{
ConnectionDenied, ConnectionId, DialError, DialFailure, FromSwarm, NetworkBehaviour,
PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm,
Expand Down
12 changes: 4 additions & 8 deletions src/rpc/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use crate::rpc::protocol::{
};
use futures::{FutureExt, SinkExt, StreamExt};
use libp2p::swarm::handler::{ConnectionEvent, FullyNegotiatedInbound, FullyNegotiatedOutbound};
use libp2p::swarm::{
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, NegotiatedSubstream, SubstreamProtocol,
};
use libp2p::PeerId;
use libp2p::swarm::{ConnectionHandler, ConnectionHandlerEvent, KeepAlive, SubstreamProtocol};
use libp2p::{PeerId, Stream};
use lighthouse_network::rpc::methods::RPCCodedResponse;
use smallvec::SmallVec;
use std::collections::hash_map::Entry;
Expand Down Expand Up @@ -48,9 +46,9 @@ pub struct SubstreamId(usize);

enum InboundSubstreamState {
// The underlying substream is not being used.
Idle(InboundFramed<NegotiatedSubstream>),
Idle(InboundFramed<Stream>),
// The underlying substream is processing responses.
Busy(Pin<Box<dyn Future<Output = Result<InboundFramed<NegotiatedSubstream>, String>> + Send>>),
Busy(Pin<Box<dyn Future<Output = Result<InboundFramed<Stream>, String>> + Send>>),
// Temporary state during processing
Poisoned,
}
Expand Down Expand Up @@ -280,8 +278,6 @@ impl<Id> Handler<Id> {
RpcRequestProtocol,
lighthouse_network::rpc::outbound::OutboundRequest<MainnetEthSpec>,
>,
// stream: <Self::OutboundProtocol as OutboundUpgradeSend>::Output,
// info: Self::OutboundOpenInfo,
) {
info!("[{}] on_fully_negotiated_outbound", self.peer_id,);
let request = outbound.info;
Expand Down
17 changes: 5 additions & 12 deletions src/rpc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use ::types::fork_context::ForkContext;
use futures::future::BoxFuture;
use futures::prelude::*;
use libp2p::core::UpgradeInfo;
use libp2p::swarm::NegotiatedSubstream;
use libp2p::{InboundUpgrade, OutboundUpgrade, PeerId};
use libp2p::{InboundUpgrade, OutboundUpgrade, PeerId, Stream};
use std::fmt::{Display, Formatter};
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -178,21 +177,15 @@ impl UpgradeInfo for RpcRequestProtocol {
}
}

pub(crate) type OutboundFramed = Framed<
Compat<NegotiatedSubstream>,
lighthouse_network::rpc::codec::OutboundCodec<MainnetEthSpec>,
>;
pub(crate) type OutboundFramed =
Framed<Compat<Stream>, lighthouse_network::rpc::codec::OutboundCodec<MainnetEthSpec>>;

impl OutboundUpgrade<NegotiatedSubstream> for RpcRequestProtocol {
impl OutboundUpgrade<Stream> for RpcRequestProtocol {
type Output = OutboundFramed;
type Error = lighthouse_network::rpc::RPCError;
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;

fn upgrade_outbound(
self,
socket: NegotiatedSubstream,
protocol_id: Self::Info,
) -> Self::Future {
fn upgrade_outbound(self, socket: Stream, protocol_id: Self::Info) -> Self::Future {
info!(
"[{}] RpcRequestProtocol::upgrade_outbound: request: {:?}",
self.request.peer_id, self.request.request
Expand Down

0 comments on commit ab28cd0

Please sign in to comment.