Skip to content

Commit

Permalink
Merge pull request #1987 from waku-org/feat/max-inbound-ping
Browse files Browse the repository at this point in the history
feat: add libp2p option for max ping connections
  • Loading branch information
adklempner authored Apr 29, 2024
2 parents 73d4f19 + fa523b7 commit bc98b4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/interfaces/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export type CreateLibp2pOptions = Libp2pOptions & {
* @default false
*/
hideWebSocketInfo?: boolean;
pingMaxInboundStreams?: number;
};
11 changes: 9 additions & 2 deletions packages/sdk/src/utils/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import { wakuGossipSub } from "@waku/relay";
import { ensureShardingConfigured } from "@waku/utils";
import { createLibp2p } from "libp2p";

import { CreateWakuNodeOptions, DefaultUserAgent } from "../waku.js";
import {
CreateWakuNodeOptions,
DefaultPingMaxInboundStreams,
DefaultUserAgent
} from "../waku.js";

import { defaultPeerDiscoveries } from "./discovery.js";

Expand Down Expand Up @@ -70,7 +74,10 @@ export async function defaultLibp2p(
identify: identify({
agentVersion: userAgent ?? DefaultUserAgent
}),
ping: ping(),
ping: ping({
maxInboundStreams:
options?.pingMaxInboundStreams ?? DefaultPingMaxInboundStreams
}),
...metadataService,
...pubsubService,
...options?.services
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/waku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { subscribeToContentTopic } from "./utils/content_topic.js";
export const DefaultPingKeepAliveValueSecs = 5 * 60;
export const DefaultRelayKeepAliveValueSecs = 5 * 60;
export const DefaultUserAgent = "js-waku";
export const DefaultPingMaxInboundStreams = 10;

const log = new Logger("waku");

Expand Down

0 comments on commit bc98b4f

Please sign in to comment.