fix
This commit is contained in:
parent
780d357c0b
commit
2dbbd6adde
1 changed files with 14 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ export class LiquidityProvider {
|
||||||
invoicePaidCb: InvoicePaidCb
|
invoicePaidCb: InvoicePaidCb
|
||||||
connecting = false
|
connecting = false
|
||||||
readyInterval: NodeJS.Timeout
|
readyInterval: NodeJS.Timeout
|
||||||
|
queue: { res: (usable: boolean) => void }[] = []
|
||||||
// make the sub process accept client
|
// make the sub process accept client
|
||||||
constructor(pubDestination: string, invoicePaidCb: InvoicePaidCb) {
|
constructor(pubDestination: string, invoicePaidCb: InvoicePaidCb) {
|
||||||
if (!pubDestination) {
|
if (!pubDestination) {
|
||||||
|
|
@ -46,6 +47,18 @@ export class LiquidityProvider {
|
||||||
}, 1000)
|
}, 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 = () => {
|
Stop = () => {
|
||||||
clearInterval(this.readyInterval)
|
clearInterval(this.readyInterval)
|
||||||
}
|
}
|
||||||
|
|
@ -57,6 +70,7 @@ export class LiquidityProvider {
|
||||||
if (this.latestMaxWithdrawable === null) {
|
if (this.latestMaxWithdrawable === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.queue.forEach(q => q.res(true))
|
||||||
this.log("subbing to user operations")
|
this.log("subbing to user operations")
|
||||||
this.client.GetLiveUserOperations(res => {
|
this.client.GetLiveUserOperations(res => {
|
||||||
console.log("got user operation", res)
|
console.log("got user operation", res)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue