Skip to content

Commit 1b41569

Browse files
fix: remove initialising peer-exchange while creating a node (#1158)
* remove peer-exchange from @waku/core - also removes the manual test for peer-exchange (assumption is that the only way to initialise peer-exchange is through libp2p's peerDiscovery and not manually) (ref: #1158 (comment)) # Please enter the commit message for your changes. Lines starting * fix: build * update interop test * decrease test duration for px auto discovery * rm: only for tests * address comment
1 parent fa6ecd6 commit 1b41569

File tree

9 files changed

+110
-135
lines changed

9 files changed

+110
-135
lines changed

package-lock.json

+53-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/lib/wait_for_remote_peer.ts

-8
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ export async function waitForRemotePeer(
6060
promises.push(waitForConnectedPeer(waku.filter));
6161
}
6262

63-
if (protocols.includes(Protocols.PeerExchange)) {
64-
if (!waku.peerExchange)
65-
throw new Error(
66-
"Cannot wait for Peer Exchange peer: protocol not mounted"
67-
);
68-
promises.push(waitForConnectedPeer(waku.peerExchange));
69-
}
70-
7163
if (timeoutMs) {
7264
await rejectOnTimeout(
7365
Promise.all(promises),

packages/core/src/lib/waku.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import type { Multiaddr } from "@multiformats/multiaddr";
66
import type {
77
IFilter,
88
ILightPush,
9-
IPeerExchange,
109
IRelay,
1110
IStore,
12-
PeerExchangeComponents,
1311
Waku,
1412
} from "@waku/interfaces";
1513
import { Protocols } from "@waku/interfaces";
@@ -53,7 +51,6 @@ export class WakuNode implements Waku {
5351
public store?: IStore;
5452
public filter?: IFilter;
5553
public lightPush?: ILightPush;
56-
public peerExchange?: IPeerExchange;
5754

5855
private pingKeepAliveTimers: {
5956
[peer: string]: ReturnType<typeof setInterval>;
@@ -67,8 +64,7 @@ export class WakuNode implements Waku {
6764
libp2p: Libp2p,
6865
store?: (libp2p: Libp2p) => IStore,
6966
lightPush?: (libp2p: Libp2p) => ILightPush,
70-
filter?: (libp2p: Libp2p) => IFilter,
71-
peerExchange?: (components: PeerExchangeComponents) => IPeerExchange
67+
filter?: (libp2p: Libp2p) => IFilter
7268
) {
7369
this.libp2p = libp2p;
7470

@@ -82,13 +78,6 @@ export class WakuNode implements Waku {
8278
this.lightPush = lightPush(libp2p);
8379
}
8480

85-
if (peerExchange) {
86-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
87-
// @ts-ignore: Libp2p is now hiding internal components but peer discovery
88-
// implementation still expect to receive said components.
89-
this.peerExchange = peerExchange(libp2p.components);
90-
}
91-
9281
if (isRelay(libp2p.pubsub)) {
9382
this.relay = libp2p.pubsub;
9483
}
@@ -97,8 +86,7 @@ export class WakuNode implements Waku {
9786
"Waku node created",
9887
this.libp2p.peerId.toString(),
9988
`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this
100-
.lightPush}, filter: ${!!this.filter}, peer exchange: ${!!this
101-
.peerExchange} `
89+
.lightPush}, filter: ${!!this.filter}} `
10290
);
10391

10492
this.pingKeepAliveTimers = {};
@@ -156,7 +144,6 @@ export class WakuNode implements Waku {
156144
this.store && _protocols.push(Protocols.Store);
157145
this.filter && _protocols.push(Protocols.Filter);
158146
this.lightPush && _protocols.push(Protocols.LightPush);
159-
this.peerExchange && _protocols.push(Protocols.PeerExchange);
160147
}
161148

162149
const codecs: string[] = [];
@@ -197,16 +184,6 @@ export class WakuNode implements Waku {
197184
}
198185
}
199186

200-
if (_protocols.includes(Protocols.PeerExchange)) {
201-
if (this.peerExchange) {
202-
codecs.push(this.peerExchange.multicodec);
203-
} else {
204-
log(
205-
"Peer Exchange codec not included in dial codec: protocol not mounted locally"
206-
);
207-
}
208-
}
209-
210187
log(`Dialing to ${peer.toString()} with protocols ${_protocols}`);
211188

212189
return this.libp2p.dialProtocol(peer, codecs);

0 commit comments

Comments
 (0)