From bca4fe4f979703198f7e6767841bf9148f347b54 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sun, 5 Feb 2023 23:01:06 +0530 Subject: [PATCH] Bug fix - Fixed: data inconsistency and continuity lost in chain querying of tx details - Fixed: Not getting response when query has no tx. (ie, either address has no tx, or using the most recent tx as the key in `after` option) --- lib/services/address/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 88c627a4..f58ccb6f 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -219,7 +219,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream results.items.unshift(tx); //using unshift, so that recent tx (low) are at front if(results.items.length > MAX_TX_QUERY_LIMIT) { //remove items from array when overflown - results.items.sort((a, b) => b.__height - a.__height || a.txid().localeCompare(b.txid())); + results.items.sort((a, b) => b.__height - a.__height || b.txid().localeCompare(a.txid())); let del_count = options.old_support ? results.items.length : results.items.length - MAX_TX_QUERY_LIMIT; let start_index = options.old_support ? MAX_TX_QUERY_LIMIT : 0; results.items.splice(start_index, del_count); @@ -238,7 +238,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream } //sort items in desc block-height, then asc txid (if same height) - results.items.sort((a, b) => b.__height - a.__height || a.txid().localeCompare(b.txid())); + results.items.sort((a, b) => b.__height - a.__height || b.txid().localeCompare(a.txid())); results.totalCount = parseInt(results.totalCount.toFixed()); //Quick support for `from` and `to` options (DEPRECATED! Not recommeded to use) @@ -991,7 +991,11 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre //wait for queue to complete function(next) { - q.drain = () => next(); + if(!q.started) //No tx in query + return next(); + + else + q.drain = () => next(); }