Skip to content

Commit

Permalink
ensure numPeersToUse is respected
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko committed Oct 12, 2024
1 parent 9ec36c3 commit 0297682
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/sdk/src/protocols/base_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ export class BaseProtocolSDK implements IBaseProtocolSDK {
) {
this.log = new Logger(`sdk:${core.multicodec}`);

this.peerManager = new PeerManager(connectionManager, core, this.log);

this.numPeersToUse = options?.numPeersToUse ?? DEFAULT_NUM_PEERS_TO_USE;
const maintainPeersInterval =
options?.maintainPeersInterval ?? DEFAULT_MAINTAIN_PEERS_INTERVAL;

this.peerManager = new PeerManager(connectionManager, core, this.log);

this.log.info(
`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${maintainPeersInterval}ms`
);
void this.startMaintainPeersInterval(maintainPeersInterval);
}

public get connectedPeers(): Peer[] {
return this.peerManager.getPeers();
return this.peerManager.getPeers().slice(0, this.numPeersToUse);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/waku/waku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class WakuNode implements IWaku {

public constructor(
public readonly pubsubTopics: PubsubTopic[],
options: WakuOptions,
options: CreateWakuNodeOptions,
libp2p: Libp2p,
protocolsEnabled: ProtocolsEnabled,
relay?: IRelay
Expand Down Expand Up @@ -111,12 +111,12 @@ export class WakuNode implements IWaku {
}

if (protocolsEnabled.lightpush) {
const lightPush = wakuLightPush(this.connectionManager);
const lightPush = wakuLightPush(this.connectionManager, options);
this.lightPush = lightPush(libp2p);
}

if (protocolsEnabled.filter) {
const filter = wakuFilter(this.connectionManager);
const filter = wakuFilter(this.connectionManager, options);
this.filter = filter(libp2p);
}

Expand Down

0 comments on commit 0297682

Please sign in to comment.