init retry mechanism
This commit is contained in:
parent
a79e0fe4ec
commit
78dc828624
1 changed files with 10 additions and 1 deletions
|
|
@ -83,7 +83,16 @@ export class Unlocker {
|
||||||
const initRes = await unlocker.initWallet(req, DeadLineMetadata(60 * 1000))
|
const initRes = await unlocker.initWallet(req, DeadLineMetadata(60 * 1000))
|
||||||
const adminMacaroon = Buffer.from(initRes.response.adminMacaroon).toString('hex')
|
const adminMacaroon = Buffer.from(initRes.response.adminMacaroon).toString('hex')
|
||||||
const ln = this.GetLightningClient(lndCert, adminMacaroon)
|
const ln = this.GetLightningClient(lndCert, adminMacaroon)
|
||||||
const info = await this.GetLndInfo(ln)
|
|
||||||
|
// Retry mechanism to ensure LND is ready
|
||||||
|
let info;
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
info = await this.GetLndInfo(ln);
|
||||||
|
if (info.ok) break;
|
||||||
|
this.log("LND not ready, retrying in 5 seconds...");
|
||||||
|
await new Promise(res => setTimeout(res, 5000));
|
||||||
|
}
|
||||||
|
|
||||||
if (!info.ok) {
|
if (!info.ok) {
|
||||||
throw new Error("failed to init lnd wallet " + info.failure)
|
throw new Error("failed to init lnd wallet " + info.failure)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue