Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
LL-1589 more robust bitcoin retry (#1835)
Browse files Browse the repository at this point in the history
* fix bot

* fix sync error exception process
  • Loading branch information
hzheng-ledger authored and lambertkevin committed Apr 11, 2022
1 parent 77dfa66 commit b9d52ef
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/families/bitcoin/wallet-btc/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,29 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {

// TODO add a test for failure (at the sync level)
const client = await this.client.acquire();
const res = (
await client.client.get(url, {
params,
// some altcoin may have outputs with values > MAX_SAFE_INTEGER
transformResponse: (string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
JSONBigNumber.parse(string, (key: string, value: any) => {
if (BigNumber.isBigNumber(value)) {
if (key === "value") {
return value.toString();
let res: { txs: TX[] } = { txs: [] };
try {
res = (
await client.client.get(url, {
params,
// some altcoin may have outputs with values > MAX_SAFE_INTEGER
transformResponse: (string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
JSONBigNumber.parse(string, (key: string, value: any) => {
if (BigNumber.isBigNumber(value)) {
if (key === "value") {
return value.toString();
}
return value.toNumber();
}

return value.toNumber();
}
return value;
}),
})
).data as { txs: TX[] };
await this.client.release(client);

return value;
}),
})
).data;
} finally {
await this.client.release(client);
}
this.emit("fetched-address-transaction", { url, params, res });

return res;
}

Expand Down Expand Up @@ -305,7 +306,6 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
params.block_hash = lastTx.block.hash;
}
}

const res = await this.fetchTxs(address, params);

const hydratedTxs: TX[] = [];
Expand Down

0 comments on commit b9d52ef

Please sign in to comment.