Skip to content

Commit 0297682

Browse files
committed
ensure numPeersToUse is respected
1 parent 9ec36c3 commit 0297682

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/sdk/src/protocols/base_protocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ export class BaseProtocolSDK implements IBaseProtocolSDK {
2929
) {
3030
this.log = new Logger(`sdk:${core.multicodec}`);
3131

32-
this.peerManager = new PeerManager(connectionManager, core, this.log);
33-
3432
this.numPeersToUse = options?.numPeersToUse ?? DEFAULT_NUM_PEERS_TO_USE;
3533
const maintainPeersInterval =
3634
options?.maintainPeersInterval ?? DEFAULT_MAINTAIN_PEERS_INTERVAL;
3735

36+
this.peerManager = new PeerManager(connectionManager, core, this.log);
37+
3838
this.log.info(
3939
`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${maintainPeersInterval}ms`
4040
);
4141
void this.startMaintainPeersInterval(maintainPeersInterval);
4242
}
4343

4444
public get connectedPeers(): Peer[] {
45-
return this.peerManager.getPeers();
45+
return this.peerManager.getPeers().slice(0, this.numPeersToUse);
4646
}
4747

4848
/**

packages/sdk/src/waku/waku.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class WakuNode implements IWaku {
7272

7373
public constructor(
7474
public readonly pubsubTopics: PubsubTopic[],
75-
options: WakuOptions,
75+
options: CreateWakuNodeOptions,
7676
libp2p: Libp2p,
7777
protocolsEnabled: ProtocolsEnabled,
7878
relay?: IRelay
@@ -111,12 +111,12 @@ export class WakuNode implements IWaku {
111111
}
112112

113113
if (protocolsEnabled.lightpush) {
114-
const lightPush = wakuLightPush(this.connectionManager);
114+
const lightPush = wakuLightPush(this.connectionManager, options);
115115
this.lightPush = lightPush(libp2p);
116116
}
117117

118118
if (protocolsEnabled.filter) {
119-
const filter = wakuFilter(this.connectionManager);
119+
const filter = wakuFilter(this.connectionManager, options);
120120
this.filter = filter(libp2p);
121121
}
122122

0 commit comments

Comments
 (0)