diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 08de11c6..0cf0d0fb 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -658,10 +658,19 @@ AddressService.prototype.stop = function(callback) { AddressService.prototype._getTxidStream = function(address, options) { - var start = this._encoding.encodeAddressIndexKey(address); + var start; + if(options.after) { + start = this._encoding.encodeAddressIndexKey(address, options.start, options.after, 0xffffffff, 1, 0xffffffff); //0xffffffff is for getting after the txid + } else { + start = this._encoding.encodeAddressIndexKey(address, options.start); + } + + var endHeightBuf = new Buffer(4); + endHeightBuf.writeUInt32BE(options.end); + var end = Buffer.concat([ start.slice(0, address.length + 4), - options.endHeightBuf, + endHeightBuf, new Buffer(new Array(83).join('f'), 'hex') ]); @@ -718,9 +727,6 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal var results = []; - options.endHeightBuf = new Buffer(4); - options.endHeightBuf.writeUInt32BE(options.end); - if (_.isUndefined(options.queryMempool)) { options.queryMempool = true; } @@ -801,13 +807,6 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre options.queryMempool = true; } - options.endHeightBuf = new Buffer(4); - options.endHeightBuf.writeUInt32BE(options.end); - - if (_.isUndefined(options.queryMempool)) { - options.queryMempool = true; - } - //declare the queue to process tx data var tmpTxList = {}; //store processed txid temporarily to ignore duplication @@ -889,6 +888,31 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre mempoolTxids.map(id => q.push(id, chunkCallback)); next(); }, + + function(next){ + + if(_.isUndefined(options.after)) { + return next(); + } + + self._transaction.getTransaction(id.txid, options, function(err, tx) { + + if(tx && tx.confirmations && tx.height >= options.start) { + + options.start = tx.height; + + } else { + + delete options.after; + + } + + next(); + + }); + + }, + // stream the rest of the confirmed txids out of the address index function(next) {