add started flag
This commit is contained in:
parent
e72eab4337
commit
524245b82c
|
@ -38,9 +38,12 @@ class RequestClient {
|
||||||
/** Cache. */
|
/** Cache. */
|
||||||
public readonly wakuMessages: Set<string>
|
public readonly wakuMessages: Set<string>
|
||||||
|
|
||||||
constructor(waku: WakuLight) {
|
private started: boolean
|
||||||
|
|
||||||
|
constructor(waku: WakuLight, started = false) {
|
||||||
this.waku = waku
|
this.waku = waku
|
||||||
this.wakuMessages = new Set()
|
this.wakuMessages = new Set()
|
||||||
|
this.started = started
|
||||||
}
|
}
|
||||||
|
|
||||||
static async start(options: RequestClientOptions): Promise<RequestClient> {
|
static async start(options: RequestClientOptions): Promise<RequestClient> {
|
||||||
|
@ -67,7 +70,9 @@ class RequestClient {
|
||||||
await waku.start()
|
await waku.start()
|
||||||
await waitForRemotePeer(waku, [Protocols.Store], 10 * 1000)
|
await waitForRemotePeer(waku, [Protocols.Store], 10 * 1000)
|
||||||
|
|
||||||
client = new RequestClient(waku)
|
const started = true
|
||||||
|
|
||||||
|
client = new RequestClient(waku, started)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (waku) {
|
if (waku) {
|
||||||
await waku.stop()
|
await waku.stop()
|
||||||
|
@ -80,7 +85,14 @@ class RequestClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stop() {
|
public async stop() {
|
||||||
|
if (!this.started) {
|
||||||
|
// todo?: throw error
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
await this.waku.stop()
|
await this.waku.stop()
|
||||||
|
|
||||||
|
this.started = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public fetchCommunity = async (
|
public fetchCommunity = async (
|
||||||
|
|
Loading…
Reference in New Issue