mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-03-15 07:20:49 +00:00
feat: check connection on client peer start
Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>
This commit is contained in:
parent
5c346f6566
commit
16c07f4363
@ -25,6 +25,7 @@ import { IMarineHost } from "../marine/interfaces.js";
|
||||
import { relayOptionToMultiaddr } from "../util/libp2pUtils.js";
|
||||
import { logger } from "../util/logger.js";
|
||||
|
||||
import { checkConnection } from './checkConnection.js'
|
||||
import {
|
||||
ClientConfig,
|
||||
IFluenceClient,
|
||||
@ -128,7 +129,14 @@ export class ClientPeer extends FluencePeer implements IFluenceClient {
|
||||
log.trace("connecting to Fluence network");
|
||||
this.changeConnectionState("connecting");
|
||||
await super.start();
|
||||
// TODO: check connection (`checkConnection` function) here
|
||||
|
||||
const connected = await checkConnection(this);
|
||||
if (!connected) {
|
||||
this.changeConnectionState("disconnected");
|
||||
log.trace("Disconnected");
|
||||
throw new Error(`Failed to establish a connection with ClientPeer ID '${this.getPeerId()}'`);
|
||||
}
|
||||
|
||||
this.changeConnectionState("connected");
|
||||
log.trace("connected");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user