Skip to content

Commit

Permalink
fix: ignore discovered peers with no multiaddrs
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Jul 7, 2023
1 parent 1de881b commit fd36917
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/beacon-node/src/network/peers/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum DiscoveredPeerStatus {
attempt_dial = "attempt_dial",
cached = "cached",
dropped = "dropped",
no_multiaddrs = "no_multiaddrs",
}

type UnixMs = number;
Expand Down Expand Up @@ -267,10 +268,17 @@ export class PeerDiscovery {
}

/**
* Progressively called by libp2p peer discovery as a result of any query.
* Progressively called by libp2p as a result of peer discovery or updates to its peer store
*/
private onDiscoveredPeer = (evt: CustomEvent<PeerInfo>): void => {
const {id, multiaddrs} = evt.detail;

// libp2p may send us PeerInfos without multiaddrs
if (multiaddrs.length === 0) {
this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.no_multiaddrs});
return;
}

const attnets = zeroAttnets;
const syncnets = zeroSyncnets;
const status = this.handleDiscoveredPeer(id, multiaddrs[0], attnets, syncnets);
Expand Down

0 comments on commit fd36917

Please sign in to comment.