From 9a00622de4134136cc6612ab18e94f320f0d2735 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Tue, 7 Nov 2017 21:37:54 -0500 Subject: [PATCH] Fixed getAddressHistory. --- lib/services/address/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index a580d4f5..e65bbd93 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -50,7 +50,6 @@ AddressService.dependencies = [ // in are [addr1, addr2, addr3], then if addr3 has tx1 at height 10, addr2 has tx2 at height 9 and tx1 has no txs, // then I would pass back [tx1, tx2] in that order AddressService.prototype.getAddressHistory = function(addresses, options, callback) { - var self = this; options = options || {}; @@ -78,7 +77,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, callba options.txIdList = lodash.uniqWith(options.txIdList, lodash.isEqual); options.txIdList = lodash.orderBy(options.txIdList, ['height'], ['desc']); - +console.log(options.txIdList); self._getAddressTxHistory(options, function(err, txList) { if (err) { @@ -423,6 +422,8 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal options.start = options.start || 0; options.end = options.end || 0xffffffff; + var results = []; + options.endHeightBuf = new Buffer(4); options.endHeightBuf.writeUInt32BE(options.end); @@ -449,7 +450,7 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal return next(); } - options.txIdList = mempoolTxids; + results = mempoolTxids; next(); }, // stream the rest of the confirmed txids out of the address index @@ -468,12 +469,13 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal }); txIdTransformStream.on('end', function() { + options.txIdList = options.txIdList.concat(results); next(); }); txIdTransformStream._transform = function(chunk, enc, callback) { var txInfo = self._encoding.decodeAddressIndexKey(chunk); - options.txIdList.push({ txid: txInfo.txid, height: txInfo.height }); + results.push({ txid: txInfo.txid, height: txInfo.height }); callback(); };