feat(swarm)!: report connections to our own PeerId in separate error (#3377)

Previously, inbound connections that happened to resolve to our own `PeerId` were reported as `WrongPeerId`. With this patch, we now report those in a dedicated `LocalPeerId` error.

Related: #3205.
This commit is contained in:
Anton
2023-01-26 11:20:23 +04:00
committed by GitHub
parent 90af08cb59
commit 9f7145912a
6 changed files with 30 additions and 10 deletions

View File

@ -228,7 +228,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
libp2p_swarm::DialError::ConnectionLimit(_) => {
record(OutgoingConnectionErrorError::ConnectionLimit)
}
libp2p_swarm::DialError::LocalPeerId => {
libp2p_swarm::DialError::LocalPeerId { .. } => {
record(OutgoingConnectionErrorError::LocalPeerId)
}
libp2p_swarm::DialError::NoAddresses => {
@ -361,6 +361,7 @@ struct IncomingConnectionErrorLabels {
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
enum PendingInboundConnectionError {
WrongPeerId,
LocalPeerId,
TransportErrorMultiaddrNotSupported,
TransportErrorOther,
Aborted,
@ -373,6 +374,9 @@ impl From<&libp2p_swarm::PendingInboundConnectionError> for PendingInboundConnec
libp2p_swarm::PendingInboundConnectionError::WrongPeerId { .. } => {
PendingInboundConnectionError::WrongPeerId
}
libp2p_swarm::PendingInboundConnectionError::LocalPeerId { .. } => {
PendingInboundConnectionError::LocalPeerId
}
libp2p_swarm::PendingInboundConnectionError::ConnectionLimit(_) => {
PendingInboundConnectionError::ConnectionLimit
}