Skip to content

Commit c3e648e

Browse files
committed
autonat/behaviour: remove no longer needed inject methods
1 parent fb0d273 commit c3e648e

File tree

1 file changed

+3
-116
lines changed

1 file changed

+3
-116
lines changed

protocols/autonat/src/behaviour.rs

Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ pub use as_server::{InboundProbeError, InboundProbeEvent};
2929
use futures_timer::Delay;
3030
use instant::Instant;
3131
use libp2p_core::{
32-
connection::ConnectionId, multiaddr::Protocol, transport::ListenerId, ConnectedPoint, Endpoint,
32+
connection::ConnectionId, multiaddr::Protocol, ConnectedPoint, Endpoint,
3333
Multiaddr, PeerId,
3434
};
3535
use libp2p_request_response::{
36-
handler::RequestResponseHandlerEvent, ProtocolSupport, RequestId, RequestResponse,
36+
ProtocolSupport, RequestId, RequestResponse,
3737
RequestResponseConfig, RequestResponseEvent, RequestResponseMessage, ResponseChannel,
3838
};
3939
use libp2p_swarm::{
40-
behaviour::FromSwarm, DialError, IntoConnectionHandler, NetworkBehaviour,
40+
behaviour::FromSwarm, DialError, NetworkBehaviour,
4141
NetworkBehaviourAction, PollParameters,
4242
};
4343
use std::{
@@ -428,78 +428,6 @@ impl NetworkBehaviour for Behaviour {
428428
type ConnectionHandler = <RequestResponse<AutoNatCodec> as NetworkBehaviour>::ConnectionHandler;
429429
type OutEvent = Event;
430430

431-
fn inject_connection_established(
432-
&mut self,
433-
peer: &PeerId,
434-
conn: &ConnectionId,
435-
endpoint: &ConnectedPoint,
436-
failed_addresses: Option<&Vec<Multiaddr>>,
437-
other_established: usize,
438-
) {
439-
let failed_addresses = failed_addresses
440-
.map(|v| v.as_slice())
441-
.unwrap_or_else(|| &[]);
442-
self.on_connection_established(*peer, *conn, endpoint, failed_addresses, other_established)
443-
}
444-
445-
fn inject_connection_closed(
446-
&mut self,
447-
peer: &PeerId,
448-
conn: &ConnectionId,
449-
endpoint: &ConnectedPoint,
450-
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
451-
remaining_established: usize,
452-
) {
453-
self.on_connection_closed(*peer, *conn, endpoint, handler, remaining_established)
454-
}
455-
456-
fn inject_dial_failure(
457-
&mut self,
458-
peer: Option<PeerId>,
459-
handler: Self::ConnectionHandler,
460-
error: &DialError,
461-
) {
462-
self.on_dial_failure(peer, handler, error)
463-
}
464-
465-
fn inject_address_change(
466-
&mut self,
467-
peer: &PeerId,
468-
conn: &ConnectionId,
469-
old: &ConnectedPoint,
470-
new: &ConnectedPoint,
471-
) {
472-
self.on_address_change(*peer, *conn, old, new)
473-
}
474-
475-
fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) {
476-
self.inner.on_swarm_event(FromSwarm::NewListenAddr {
477-
listener_id: id,
478-
addr,
479-
});
480-
self.as_client().on_new_address();
481-
}
482-
483-
fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) {
484-
self.inner.on_swarm_event(FromSwarm::ExpiredListenAddr {
485-
listener_id: id,
486-
addr,
487-
});
488-
self.as_client().on_expired_address(addr);
489-
}
490-
491-
fn inject_new_external_addr(&mut self, addr: &Multiaddr) {
492-
self.inner
493-
.on_swarm_event(FromSwarm::NewExternalAddr { addr });
494-
self.as_client().on_new_address();
495-
}
496-
497-
fn inject_expired_external_addr(&mut self, addr: &Multiaddr) {
498-
self.inner
499-
.on_swarm_event(FromSwarm::ExpiredExternalAddr { addr });
500-
self.as_client().on_expired_address(addr);
501-
}
502-
503431
fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters) -> Poll<Action> {
504432
loop {
505433
if let Some(event) = self.pending_out_events.pop_front() {
@@ -553,47 +481,6 @@ impl NetworkBehaviour for Behaviour {
553481
self.inner.addresses_of_peer(peer)
554482
}
555483

556-
fn inject_event(
557-
&mut self,
558-
peer_id: PeerId,
559-
conn: ConnectionId,
560-
event: RequestResponseHandlerEvent<AutoNatCodec>,
561-
) {
562-
self.inner.on_connection_handler_event(peer_id, conn, event)
563-
}
564-
565-
fn inject_listen_failure(
566-
&mut self,
567-
local_addr: &Multiaddr,
568-
send_back_addr: &Multiaddr,
569-
handler: Self::ConnectionHandler,
570-
) {
571-
self.inner.on_swarm_event(FromSwarm::ListenFailure {
572-
local_addr,
573-
send_back_addr,
574-
handler,
575-
});
576-
}
577-
578-
fn inject_new_listener(&mut self, id: ListenerId) {
579-
self.inner
580-
.on_swarm_event(FromSwarm::NewListener { listener_id: id })
581-
}
582-
583-
fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn std::error::Error + 'static)) {
584-
self.inner.on_swarm_event(FromSwarm::ListenerError {
585-
listener_id: id,
586-
err,
587-
});
588-
}
589-
590-
fn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &std::io::Error>) {
591-
self.inner.on_swarm_event(FromSwarm::ListenerClosed {
592-
listener_id: id,
593-
reason,
594-
});
595-
}
596-
597484
fn on_swarm_event(&mut self, event: FromSwarm<Self::ConnectionHandler>) {
598485
match event {
599486
FromSwarm::ConnectionEstablished {

0 commit comments

Comments
 (0)