Adding option mempoolOnly in querying

- mempoolOnly option make the query in db from mempool only (ie, unconfirmed tx only
This commit is contained in:
sairajzero 2023-04-13 03:52:02 +05:30
parent 27f3993884
commit df7710ded1

View File

@ -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) {