Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions packages/core/js-client/src/connection/RelayConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class RelayConnection implements IConnection {
return;
}

const lib2p2Peer = await createLibp2p({
this.lib2p2Peer = await createLibp2p({
peerId: this.config.peerId,
transports: [
webSockets({
Expand All @@ -121,15 +121,16 @@ export class RelayConnection implements IConnection {
denyDialMultiaddr: () => Promise.resolve(false)
},
services: {
identify: identifyService({
runOnConnectionOpen: false,
}),
identify: identifyService(),
ping: pingService()
}
});

this.lib2p2Peer = lib2p2Peer;
this.lib2p2Peer.start();
const supportedProtocols = (await this.lib2p2Peer.peerStore.get(this.lib2p2Peer.peerId)).protocols;
await this.lib2p2Peer.peerStore.patch(this.lib2p2Peer.peerId, {
protocols: [...supportedProtocols, PROTOCOL_NAME]
});

await this.connect();
}

Expand All @@ -156,16 +157,8 @@ export class RelayConnection implements IConnection {
);
}

/*
TODO:: find out why this doesn't work and a new connection has to be established each time
if (this._connection.streams.length !== 1) {
throw new Error('Incorrect number of streams in FluenceConnection');
}

const sink = this._connection.streams[0].sink;
*/

log.trace('sending particle...');
// Reusing active connection here
const stream = await this.lib2p2Peer.dialProtocol(this.relayAddress, PROTOCOL_NAME);
log.trace('created stream with id ', stream.id);
const sink = stream.sink;
Expand Down