Update bulk /txs to use new failover router, internal-api path

This commit is contained in:
Mononaut 2023-08-16 18:30:18 +09:00
parent 38909cfc42
commit 156b5d0b3c
No known key found for this signature in database
GPG key ID: A3F058E41374C04E
2 changed files with 4 additions and 1 deletions

View file

@ -214,7 +214,7 @@ class ElectrsApi implements AbstractBitcoinApi {
}
async $getRawTransactions(txids: string[]): Promise<IEsploraApi.Transaction[]> {
return this.$postWrapper<IEsploraApi.Transaction[]>(config.ESPLORA.REST_API_URL + '/txs', txids, 'json');
return this.failoverRouter.$post<IEsploraApi.Transaction[]>('/internal-api/txs', txids, 'json');
}
async $getMempoolTransactions(txids: string[]): Promise<IEsploraApi.Transaction[]> {

View file

@ -505,10 +505,13 @@ class RbfCache {
if (config.MEMPOOL.BACKEND === 'esplora') {
const sliceLength = 10000;
let count = 0;
for (let i = 0; i < Math.ceil(txids.length / sliceLength); i++) {
const slice = txids.slice(i * sliceLength, (i + 1) * sliceLength);
try {
const txs = await bitcoinApi.$getRawTransactions(slice);
count += txs.length;
logger.info(`Fetched ${count} of ${txids.length} unknown-status RBF transactions from esplora`);
processTxs(txs);
} catch (err) {
logger.err('failed to fetch some cached rbf transactions');