From df7710ded1d0f5cbf1e844cfd550c52cfeb0d113 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Thu, 13 Apr 2023 03:52:02 +0530 Subject: [PATCH] Adding option mempoolOnly in querying - mempoolOnly option make the query in db from mempool only (ie, unconfirmed tx only --- lib/services/address/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 81e18930..a93b9418 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -189,6 +189,10 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream options.queryMempool = true; } + if (_.isUndefined(options.mempoolOnly)) { + options.mempoolOnly = false; + } + var old_support = false; //Quick support for `from` and `to` options (DEPRECATED! Not recommeded to use) if( !_.isUndefined(options.from) || !_.isUndefined(options.to)) { @@ -859,6 +863,10 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre options.queryMempool = true; } + if (_.isUndefined(options.mempoolOnly)) { + options.mempoolOnly = false; + } + //declare the queue to process tx data var tmpTxList = {}; //store processed txid temporarily to ignore duplication @@ -950,6 +958,10 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre // stream the rest of the confirmed txids out of the address index function(next) { + if (options.mempoolOnly) { //Option to query from mempool only (ie, unconfirmed txs only) + return next(); + } + var txIdTransformStream = new Transform({ objectMode: true }); txIdTransformStream._flush = function(cb) {