Skip to content

Commit

Permalink
Discv5: Do not issue FINDNODES right after the start
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Nov 12, 2021
1 parent 91f3fef commit 5d75192
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/lodestar/src/network/peers/peerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export class PeerManager {

private seenPeers = new Set<string>();

private firstHearbeat = true;

constructor(modules: PeerManagerModules, opts: PeerManagerOpts) {
this.libp2p = modules.libp2p;
this.logger = modules.logger;
Expand Down Expand Up @@ -389,7 +391,9 @@ export class PeerManager {
}
}

if (this.discovery) {
// don't want to use discv5 right after it started bc the transport may not be ready at that time
// see https://github.com/ChainSafe/lodestar/issues/3423
if (this.discovery && !this.firstHearbeat) {
try {
this.discovery.discoverPeers(peersToConnect, queriesMerged);
} catch (e) {
Expand All @@ -400,6 +404,8 @@ export class PeerManager {
for (const peer of peersToDisconnect) {
void this.goodbyeAndDisconnect(peer, GoodByeReasonCode.TOO_MANY_PEERS);
}

this.firstHearbeat = false;
}

private pingAndStatusTimeouts(): void {
Expand Down

0 comments on commit 5d75192

Please sign in to comment.