feat: add libp2p option for max ping connections

This commit is contained in:
Arseniy Klempner 2024-04-26 17:19:22 -07:00
parent 73d4f19746
commit fa523b78af
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
3 changed files with 11 additions and 2 deletions

View File

@ -29,4 +29,5 @@ export type CreateLibp2pOptions = Libp2pOptions & {
* @default false * @default false
*/ */
hideWebSocketInfo?: boolean; hideWebSocketInfo?: boolean;
pingMaxInboundStreams?: number;
}; };

View File

@ -19,7 +19,11 @@ import { wakuGossipSub } from "@waku/relay";
import { ensureShardingConfigured } from "@waku/utils"; import { ensureShardingConfigured } from "@waku/utils";
import { createLibp2p } from "libp2p"; import { createLibp2p } from "libp2p";
import { CreateWakuNodeOptions, DefaultUserAgent } from "../waku.js"; import {
CreateWakuNodeOptions,
DefaultPingMaxInboundStreams,
DefaultUserAgent
} from "../waku.js";
import { defaultPeerDiscoveries } from "./discovery.js"; import { defaultPeerDiscoveries } from "./discovery.js";
@ -70,7 +74,10 @@ export async function defaultLibp2p(
identify: identify({ identify: identify({
agentVersion: userAgent ?? DefaultUserAgent agentVersion: userAgent ?? DefaultUserAgent
}), }),
ping: ping(), ping: ping({
maxInboundStreams:
options?.pingMaxInboundStreams ?? DefaultPingMaxInboundStreams
}),
...metadataService, ...metadataService,
...pubsubService, ...pubsubService,
...options?.services ...options?.services

View File

@ -23,6 +23,7 @@ import { subscribeToContentTopic } from "./utils/content_topic.js";
export const DefaultPingKeepAliveValueSecs = 5 * 60; export const DefaultPingKeepAliveValueSecs = 5 * 60;
export const DefaultRelayKeepAliveValueSecs = 5 * 60; export const DefaultRelayKeepAliveValueSecs = 5 * 60;
export const DefaultUserAgent = "js-waku"; export const DefaultUserAgent = "js-waku";
export const DefaultPingMaxInboundStreams = 10;
const log = new Logger("waku"); const log = new Logger("waku");