Skip to content

Commit e6f4787

Browse files
committed
packages/core: add disablePing option, turn off ping in replication servers
1 parent 4231dd8 commit e6f4787

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/core/src/Canvas.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { GossipLogService } from "@canvas-js/gossiplog/service"
2323

2424
export interface NetworkConfig {
2525
offline?: boolean
26+
disablePing?: boolean
2627

2728
/** array of local WebSocket multiaddrs, e.g. "/ip4/127.0.0.1/tcp/3000/ws" */
2829
listen?: string[]
@@ -96,6 +97,7 @@ export class Canvas<T extends Contract = Contract> extends EventEmitter<CanvasEv
9697
indexHistory = true,
9798
ignoreMissingActions = false,
9899
offline,
100+
disablePing,
99101
} = config
100102

101103
if (signers.length === 0) {
@@ -149,6 +151,7 @@ export class Canvas<T extends Contract = Contract> extends EventEmitter<CanvasEv
149151
public readonly messageLog: AbstractGossipLog<Action | Session, void | any>,
150152
private readonly runtime: Runtime,
151153
offline?: boolean,
154+
disablePing?: boolean,
152155
) {
153156
super()
154157
this.db = runtime.db
@@ -230,11 +233,11 @@ export class Canvas<T extends Contract = Contract> extends EventEmitter<CanvasEv
230233
}, 3000)
231234
}
232235

233-
if (offline) {
236+
if (offline && !disablePing) {
234237
this.libp2p.addEventListener("start", (event) => {
235238
startPingTimer()
236239
})
237-
} else {
240+
} else if (!disablePing) {
238241
startPingTimer()
239242
}
240243
this.libp2p.addEventListener("stop", (event) => {

packages/replication-server/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ libp2p.services.discovery.addEventListener("peer:topics", ({ detail: { topics }
5757
libp2p,
5858
indexHistory: false,
5959
ignoreMissingActions: true,
60+
disablePing: true,
6061
})
6162

6263
apps.set(appTopic, app)

0 commit comments

Comments
 (0)