Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore peers with invalid multiaddrs #1902

Merged
merged 7 commits into from
Jul 30, 2023
10 changes: 8 additions & 2 deletions packages/libp2p/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ export class Libp2pNode<T extends ServiceMap = Record<string, unknown>> extends

components.events.addEventListener('peer:update', evt => {
// if there was no peer previously in the peer store this is a new peer
if (evt.detail.previous == null) {
this.safeDispatchEvent('peer:discovery', { detail: evt.detail.peer })
if (evt.detail.previous === null) {
maschad marked this conversation as resolved.
Show resolved Hide resolved
const peerInfo: PeerInfo = {
id: evt.detail.peer.id,
multiaddrs: evt.detail.peer.addresses.map(a => a.multiaddr),
protocols: evt.detail.peer.protocols
}

this.safeDispatchEvent('peer:discovery', { detail: peerInfo })
}
})

Expand Down