mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-21 03:41:32 +00:00
fix(libp2p): Add fluence protocol to local peer store protocols [fixes DXJ-471] (#343)
Add fluence protocol to local peer store protocols
This commit is contained in:
@ -104,7 +104,7 @@ export class RelayConnection implements IConnection {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lib2p2Peer = await createLibp2p({
|
this.lib2p2Peer = await createLibp2p({
|
||||||
peerId: this.config.peerId,
|
peerId: this.config.peerId,
|
||||||
transports: [
|
transports: [
|
||||||
webSockets({
|
webSockets({
|
||||||
@ -121,15 +121,16 @@ export class RelayConnection implements IConnection {
|
|||||||
denyDialMultiaddr: () => Promise.resolve(false)
|
denyDialMultiaddr: () => Promise.resolve(false)
|
||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
identify: identifyService({
|
identify: identifyService(),
|
||||||
runOnConnectionOpen: false,
|
|
||||||
}),
|
|
||||||
ping: pingService()
|
ping: pingService()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lib2p2Peer = lib2p2Peer;
|
const supportedProtocols = (await this.lib2p2Peer.peerStore.get(this.lib2p2Peer.peerId)).protocols;
|
||||||
this.lib2p2Peer.start();
|
await this.lib2p2Peer.peerStore.patch(this.lib2p2Peer.peerId, {
|
||||||
|
protocols: [...supportedProtocols, PROTOCOL_NAME]
|
||||||
|
});
|
||||||
|
|
||||||
await this.connect();
|
await this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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...');
|
log.trace('sending particle...');
|
||||||
|
// Reusing active connection here
|
||||||
const stream = await this.lib2p2Peer.dialProtocol(this.relayAddress, PROTOCOL_NAME);
|
const stream = await this.lib2p2Peer.dialProtocol(this.relayAddress, PROTOCOL_NAME);
|
||||||
log.trace('created stream with id ', stream.id);
|
log.trace('created stream with id ', stream.id);
|
||||||
const sink = stream.sink;
|
const sink = stream.sink;
|
||||||
|
Reference in New Issue
Block a user