Browse Source

Serialize calls to bitcoind RPC

Pavel Ševčík 4 years ago
parent
commit
0398e6cfba
No known key found for this signature in database GPG Key ID: CFA54E4C0CD58DF0
  1. 9
      tracker/mempool-processor.js

9
tracker/mempool-processor.js

@ -259,7 +259,10 @@ class MempoolProcessor {
const unconfirmedTxs = await db.getUnconfirmedTransactions() const unconfirmedTxs = await db.getUnconfirmedTransactions()
if (unconfirmedTxs.length > 0) { if (unconfirmedTxs.length > 0) {
await util.parallelCall(unconfirmedTxs, tx => { const unconfirmedTxLists = util.splitList(unconfirmedTxs, 10)
await util.seriesCall(unconfirmedTxLists, async (txList) => {
return await util.parallelCall(txList, tx => {
try { try {
return this.client.getrawtransaction( { txid: tx.txnTxid, verbose: true }) return this.client.getrawtransaction( { txid: tx.txnTxid, verbose: true })
.then(async rtx => { .then(async rtx => {
@ -271,7 +274,8 @@ class MempoolProcessor {
return db.confirmTransactions([tx.txnTxid], block.blockID) return db.confirmTransactions([tx.txnTxid], block.blockID)
} }
}, },
() => { (e) => {
Logger.error(e, 'Tracker : MempoolProcessor.checkUnconfirmed()')
// Transaction not in mempool. Update LRU cache and database // Transaction not in mempool. Update LRU cache and database
TransactionsBundle.cache.del(tx.txnTxid) TransactionsBundle.cache.del(tx.txnTxid)
// TODO: Notify clients of orphaned transaction // TODO: Notify clients of orphaned transaction
@ -282,6 +286,7 @@ class MempoolProcessor {
Logger.error(e, 'Tracker : MempoolProcessor.checkUnconfirmed()') Logger.error(e, 'Tracker : MempoolProcessor.checkUnconfirmed()')
} }
}) })
})
} }
// Logs // Logs

Loading…
Cancel
Save