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

@@ -60,8 +60,17 @@ class BitcoinApi implements AbstractBitcoinApi {
});
}
$getRawTransactions(txids: string[]): Promise<IEsploraApi.Transaction[]> {
throw new Error('Method getRawTransactions not supported by the Bitcoin RPC API.');
async $getRawTransactions(txids: string[]): Promise<IEsploraApi.Transaction[]> {
const txs: IEsploraApi.Transaction[] = [];
for (const txid of txids) {
try {
const tx = await this.$getRawTransaction(txid, false, true);
txs.push(tx);
} catch (err) {
// skip failures
}
}
return txs;
}
$getMempoolTransactions(txids: string[]): Promise<IEsploraApi.Transaction[]> {
@@ -202,6 +211,10 @@ class BitcoinApi implements AbstractBitcoinApi {
return outspends;
}
async $getBatchedOutspendsInternal(txId: string[]): Promise<IEsploraApi.Outspend[][]> {
return this.$getBatchedOutspends(txId);
}
$getEstimatedHashrate(blockHeight: number): Promise<number> {
// 120 is the default block span in Core
return this.bitcoindClient.getNetworkHashPs(120, blockHeight);