mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-21 03:41:32 +00:00
fix: Fire and forget [fixes DXJ-446] (#336)
* Add test for particle and try to fix it * Fix build * Fix tests * Fix stop order * FluencePeer refactoring * mplex to yamux * Small fixes * Refactor connections * Update packages/core/js-client/src/jsPeer/FluencePeer.ts Co-authored-by: shamsartem <shamsartem@gmail.com> * Remove redundant checks * Update packages/core/js-client/src/jsPeer/FluencePeer.ts Co-authored-by: shamsartem <shamsartem@gmail.com> * Suppress very long output of raw data * Test for parallel execution * Fix test * Misc optimization * Add minRepr * Fix reset error * Latest default nox image --------- Co-authored-by: shamsartem <shamsartem@gmail.com>
This commit is contained in:
@ -55,20 +55,13 @@ export const makeClientPeerConfig = async (
|
||||
};
|
||||
|
||||
export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
private relayPeerId: PeerIdB58;
|
||||
private relayConnection: RelayConnection;
|
||||
|
||||
constructor(
|
||||
peerConfig: PeerConfig,
|
||||
relayConfig: RelayConnectionConfig,
|
||||
keyPair: KeyPair,
|
||||
marine: IMarineHost,
|
||||
) {
|
||||
const relayConnection = new RelayConnection(relayConfig);
|
||||
|
||||
super(peerConfig, keyPair, marine, new JsServiceHost(), relayConnection);
|
||||
this.relayPeerId = relayConnection.getRelayPeerId();
|
||||
this.relayConnection = relayConnection;
|
||||
super(peerConfig, keyPair, marine, new JsServiceHost(), new RelayConnection(relayConfig));
|
||||
}
|
||||
|
||||
getPeerId(): string {
|
||||
@ -83,7 +76,7 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
connectionStateChangeHandler: (state: ConnectionState) => void = () => {};
|
||||
|
||||
getRelayPeerId(): string {
|
||||
return this.relayPeerId;
|
||||
return this.internals.getRelayPeerId();
|
||||
}
|
||||
|
||||
onConnectionStateChange(handler: (state: ConnectionState) => void): ConnectionState {
|
||||
@ -115,7 +108,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
log.trace('connecting to Fluence network');
|
||||
this.changeConnectionState('connecting');
|
||||
await super.start();
|
||||
await this.relayConnection.start();
|
||||
// TODO: check connection (`checkConnection` function) here
|
||||
this.changeConnectionState('connected');
|
||||
log.trace('connected');
|
||||
@ -124,7 +116,6 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
async stop(): Promise<void> {
|
||||
log.trace('disconnecting from Fluence network');
|
||||
this.changeConnectionState('disconnecting');
|
||||
await this.relayConnection.stop();
|
||||
await super.stop();
|
||||
this.changeConnectionState('disconnected');
|
||||
log.trace('disconnected');
|
||||
|
Reference in New Issue
Block a user