From 2dbbd6addebf87de4a7b546fb918706f78fa1552 Mon Sep 17 00:00:00 2001 From: boufni95 Date: Mon, 24 Jun 2024 22:22:18 +0200 Subject: [PATCH] fix --- src/services/lnd/liquidityProvider.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/services/lnd/liquidityProvider.ts b/src/services/lnd/liquidityProvider.ts index 104c0067..ef5c4c10 100644 --- a/src/services/lnd/liquidityProvider.ts +++ b/src/services/lnd/liquidityProvider.ts @@ -24,6 +24,7 @@ export class LiquidityProvider { invoicePaidCb: InvoicePaidCb connecting = false readyInterval: NodeJS.Timeout + queue: { res: (usable: boolean) => void }[] = [] // make the sub process accept client constructor(pubDestination: string, invoicePaidCb: InvoicePaidCb) { if (!pubDestination) { @@ -46,6 +47,18 @@ export class LiquidityProvider { }, 1000) } + AwaitProviderReady = async (res: (usable: boolean) => void) => { + if (!this.pubDestination) { + res(false) + return + } + if (this.latestMaxWithdrawable !== null) { + res(true) + return + } + this.queue.push({ res }) + } + Stop = () => { clearInterval(this.readyInterval) } @@ -57,6 +70,7 @@ export class LiquidityProvider { if (this.latestMaxWithdrawable === null) { return } + this.queue.forEach(q => q.res(true)) this.log("subbing to user operations") this.client.GetLiveUserOperations(res => { console.log("got user operation", res)