Skip to content

Commit

Permalink
refactor: mark {In, Out}boundOpenInfo as deprecated
Browse files Browse the repository at this point in the history
Mark `{In, Out}boundOpenInfo` as deprecated.
May close #3268.

Pull-Request: #5242.
  • Loading branch information
drHuangMHT authored Jan 9, 2025
1 parent 28387f2 commit 4b4f197
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 278 deletions.
13 changes: 3 additions & 10 deletions protocols/autonat/src/v2/client/handler/dial_back.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ impl ConnectionHandler for Handler {
type InboundOpenInfo = ();
type OutboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
SubstreamProtocol::new(ReadyUpgrade::new(DIAL_BACK_PROTOCOL), ())
}

fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
loop {
match self.inbound.poll_next_unpin(cx) {
Poll::Pending => return Poll::Pending,
Expand All @@ -68,12 +66,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound {
Expand Down
15 changes: 4 additions & 11 deletions protocols/autonat/src/v2/client/handler/dial_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub struct Handler {
queued_events: VecDeque<
ConnectionHandlerEvent<
<Self as ConnectionHandler>::OutboundProtocol,
<Self as ConnectionHandler>::OutboundOpenInfo,
(),
<Self as ConnectionHandler>::ToBehaviour,
>,
>,
Expand Down Expand Up @@ -121,16 +121,14 @@ impl ConnectionHandler for Handler {
type InboundOpenInfo = ();
type OutboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
SubstreamProtocol::new(DeniedUpgrade, ())
}

fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
if let Some(event) = self.queued_events.pop_front() {
return Poll::Ready(event);
}
Expand Down Expand Up @@ -161,12 +159,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => {
Expand Down
13 changes: 3 additions & 10 deletions protocols/autonat/src/v2/server/handler/dial_back.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ impl ConnectionHandler for Handler {
type InboundOpenInfo = ();
type OutboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
SubstreamProtocol::new(DeniedUpgrade, ())
}

fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
if let Poll::Ready(result) = self.outbound.poll_unpin(cx) {
return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(
result
Expand All @@ -76,12 +74,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound {
Expand Down
13 changes: 3 additions & 10 deletions protocols/autonat/src/v2/server/handler/dial_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,14 @@ where
type InboundOpenInfo = ();
type OutboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
SubstreamProtocol::new(ReadyUpgrade::new(DIAL_REQUEST_PROTOCOL), ())
}

fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
loop {
match self.inbound.poll_unpin(cx) {
Poll::Ready(Ok(event)) => {
Expand All @@ -117,12 +115,7 @@ where

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound {
Expand Down
29 changes: 8 additions & 21 deletions protocols/dcutr/src/handler/relayed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct Handler {
queued_events: VecDeque<
ConnectionHandlerEvent<
<Self as ConnectionHandler>::OutboundProtocol,
<Self as ConnectionHandler>::OutboundOpenInfo,
(),
<Self as ConnectionHandler>::ToBehaviour,
>,
>,
Expand Down Expand Up @@ -98,10 +98,7 @@ impl Handler {
&mut self,
FullyNegotiatedInbound {
protocol: output, ..
}: FullyNegotiatedInbound<
<Self as ConnectionHandler>::InboundProtocol,
<Self as ConnectionHandler>::InboundOpenInfo,
>,
}: FullyNegotiatedInbound<<Self as ConnectionHandler>::InboundProtocol>,
) {
match output {
future::Either::Left(stream) => {
Expand Down Expand Up @@ -130,10 +127,7 @@ impl Handler {
&mut self,
FullyNegotiatedOutbound {
protocol: stream, ..
}: FullyNegotiatedOutbound<
<Self as ConnectionHandler>::OutboundProtocol,
<Self as ConnectionHandler>::OutboundOpenInfo,
>,
}: FullyNegotiatedOutbound<<Self as ConnectionHandler>::OutboundProtocol>,
) {
assert!(
self.endpoint.is_listener(),
Expand All @@ -156,7 +150,7 @@ impl Handler {
fn on_listen_upgrade_error(
&mut self,
ListenUpgradeError { error, .. }: ListenUpgradeError<
<Self as ConnectionHandler>::InboundOpenInfo,
(),
<Self as ConnectionHandler>::InboundProtocol,
>,
) {
Expand All @@ -168,7 +162,7 @@ impl Handler {
fn on_dial_upgrade_error(
&mut self,
DialUpgradeError { error, .. }: DialUpgradeError<
<Self as ConnectionHandler>::OutboundOpenInfo,
(),
<Self as ConnectionHandler>::OutboundProtocol,
>,
) {
Expand Down Expand Up @@ -196,7 +190,7 @@ impl ConnectionHandler for Handler {
type OutboundOpenInfo = ();
type InboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
match self.endpoint {
ConnectedPoint::Dialer { .. } => {
SubstreamProtocol::new(Either::Left(ReadyUpgrade::new(PROTOCOL_NAME)), ())
Expand Down Expand Up @@ -236,9 +230,7 @@ impl ConnectionHandler for Handler {
fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
// Return queued events.
if let Some(event) = self.queued_events.pop_front() {
return Poll::Ready(event);
Expand Down Expand Up @@ -295,12 +287,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedInbound(fully_negotiated_inbound) => {
Expand Down
16 changes: 4 additions & 12 deletions protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ impl EnabledHandler {
&mut self,
FullyNegotiatedOutbound { protocol, .. }: FullyNegotiatedOutbound<
<Handler as ConnectionHandler>::OutboundProtocol,
<Handler as ConnectionHandler>::OutboundOpenInfo,
>,
) {
let (substream, peer_kind) = protocol;
Expand All @@ -221,7 +220,7 @@ impl EnabledHandler {
) -> Poll<
ConnectionHandlerEvent<
<Handler as ConnectionHandler>::OutboundProtocol,
<Handler as ConnectionHandler>::OutboundOpenInfo,
(),
<Handler as ConnectionHandler>::ToBehaviour,
>,
> {
Expand Down Expand Up @@ -427,7 +426,7 @@ impl ConnectionHandler for Handler {
type OutboundOpenInfo = ();
type OutboundProtocol = ProtocolConfig;

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
match self {
Handler::Enabled(handler) => {
SubstreamProtocol::new(either::Either::Left(handler.listen_protocol.clone()), ())
Expand Down Expand Up @@ -462,9 +461,7 @@ impl ConnectionHandler for Handler {
fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
match self {
Handler::Enabled(handler) => handler.poll(cx),
Handler::Disabled(DisabledHandler::ProtocolUnsupported { peer_kind_sent }) => {
Expand All @@ -483,12 +480,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match self {
Handler::Enabled(handler) => {
Expand Down
21 changes: 5 additions & 16 deletions protocols/identify/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ impl Handler {
&mut self,
FullyNegotiatedInbound {
protocol: output, ..
}: FullyNegotiatedInbound<
<Self as ConnectionHandler>::InboundProtocol,
<Self as ConnectionHandler>::InboundOpenInfo,
>,
}: FullyNegotiatedInbound<<Self as ConnectionHandler>::InboundProtocol>,
) {
match output {
future::Either::Left(stream) => {
Expand Down Expand Up @@ -198,10 +195,7 @@ impl Handler {
&mut self,
FullyNegotiatedOutbound {
protocol: output, ..
}: FullyNegotiatedOutbound<
<Self as ConnectionHandler>::OutboundProtocol,
<Self as ConnectionHandler>::OutboundOpenInfo,
>,
}: FullyNegotiatedOutbound<<Self as ConnectionHandler>::OutboundProtocol>,
) {
match output {
future::Either::Left(stream) => {
Expand Down Expand Up @@ -303,7 +297,7 @@ impl ConnectionHandler for Handler {
type OutboundOpenInfo = ();
type InboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
SubstreamProtocol::new(
SelectUpgrade::new(
ReadyUpgrade::new(PROTOCOL_NAME),
Expand Down Expand Up @@ -334,7 +328,7 @@ impl ConnectionHandler for Handler {
fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Event>> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Event>> {
if let Some(event) = self.events.pop() {
return Poll::Ready(event);
}
Expand Down Expand Up @@ -413,12 +407,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedInbound(fully_negotiated_inbound) => {
Expand Down
19 changes: 4 additions & 15 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,7 @@ impl Handler {
FullyNegotiatedOutbound {
protocol: stream,
info: (),
}: FullyNegotiatedOutbound<
<Self as ConnectionHandler>::OutboundProtocol,
<Self as ConnectionHandler>::OutboundOpenInfo,
>,
}: FullyNegotiatedOutbound<<Self as ConnectionHandler>::OutboundProtocol>,
) {
if let Some(sender) = self.pending_streams.pop_front() {
let _ = sender.send(Ok(stream));
Expand All @@ -500,7 +497,6 @@ impl Handler {
&mut self,
FullyNegotiatedInbound { protocol, .. }: FullyNegotiatedInbound<
<Self as ConnectionHandler>::InboundProtocol,
<Self as ConnectionHandler>::InboundOpenInfo,
>,
) {
// If `self.allow_listening` is false, then we produced a `DeniedUpgrade` and `protocol`
Expand Down Expand Up @@ -608,7 +604,7 @@ impl ConnectionHandler for Handler {
type OutboundOpenInfo = ();
type InboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
match self.mode {
Mode::Server => SubstreamProtocol::new(Either::Left(self.protocol_config.clone()), ()),
Mode::Client => SubstreamProtocol::new(Either::Right(upgrade::DeniedUpgrade), ()),
Expand Down Expand Up @@ -719,9 +715,7 @@ impl ConnectionHandler for Handler {
fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<
ConnectionHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::ToBehaviour>,
> {
) -> Poll<ConnectionHandlerEvent<Self::OutboundProtocol, (), Self::ToBehaviour>> {
loop {
match &mut self.protocol_status {
Some(status) if !status.reported => {
Expand Down Expand Up @@ -788,12 +782,7 @@ impl ConnectionHandler for Handler {

fn on_connection_event(
&mut self,
event: ConnectionEvent<
Self::InboundProtocol,
Self::OutboundProtocol,
Self::InboundOpenInfo,
Self::OutboundOpenInfo,
>,
event: ConnectionEvent<Self::InboundProtocol, Self::OutboundProtocol>,
) {
match event {
ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => {
Expand Down
Loading

0 comments on commit 4b4f197

Please sign in to comment.