Don't overload core with mempool tx requests
This commit is contained in:
parent
f36ee36576
commit
1b2122cd35
@ -74,8 +74,18 @@ class TransactionUtils {
|
|||||||
|
|
||||||
public async $getMempoolTransactionsExtended(txids: string[], addPrevouts = false, lazyPrevouts = false, forceCore = false): Promise<MempoolTransactionExtended[]> {
|
public async $getMempoolTransactionsExtended(txids: string[], addPrevouts = false, lazyPrevouts = false, forceCore = false): Promise<MempoolTransactionExtended[]> {
|
||||||
if (forceCore || config.MEMPOOL.BACKEND !== 'esplora') {
|
if (forceCore || config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
const results = await Promise.allSettled(txids.map(txid => this.$getTransactionExtended(txid, addPrevouts, lazyPrevouts, forceCore, true)));
|
const results: MempoolTransactionExtended[] = [];
|
||||||
return (results.filter(r => r.status === 'fulfilled') as PromiseFulfilledResult<MempoolTransactionExtended>[]).map(r => r.value);
|
for (const txid of txids) {
|
||||||
|
try {
|
||||||
|
const result = await this.$getMempoolTransactionExtended(txid, addPrevouts, lazyPrevouts, forceCore);
|
||||||
|
if (result) {
|
||||||
|
results.push(result);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// skip failures
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
} else {
|
} else {
|
||||||
const transactions = await bitcoinApi.$getMempoolTransactions(txids);
|
const transactions = await bitcoinApi.$getMempoolTransactions(txids);
|
||||||
return transactions.map(transaction => {
|
return transactions.map(transaction => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user