Use new bulk endpoints to speed up forensics

This commit is contained in:
Mononaut
2023-08-17 02:42:59 +09:00
parent 7ec7ae7b95
commit 5bee54a2bf
4 changed files with 155 additions and 69 deletions

View File

@@ -301,6 +301,19 @@ class ElectrsApi implements AbstractBitcoinApi {
throw new Error('Method not implemented.');
}
async $getBatchedOutspendsInternal(txids: string[]): Promise<IEsploraApi.Outspend[][]> {
const allOutspends: IEsploraApi.Outspend[][] = [];
const sliceLength = 50;
for (let i = 0; i < Math.ceil(txids.length / sliceLength); i++) {
const slice = txids.slice(i * sliceLength, (i + 1) * sliceLength);
const sliceOutspends = await this.failoverRouter.$get<IEsploraApi.Outspend[][]>('/txs/outspends', 'json', { txids: slice.join(',') });
for (const outspends of sliceOutspends) {
allOutspends.push(outspends);
}
}
return allOutspends;
}
public startHealthChecks(): void {
this.failoverRouter.startHealthChecks();
}