diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 84ba9da0..3977219b 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -16,7 +16,7 @@ var utils = require('../../utils'); var LRU = require('lru-cache'); var XXHash = require('xxhash'); - +const MAX_TX_QUERY_LIMIT = 1000; // See rationale about this cache at function getTxList(next) const TXID_LIST_CACHE_ITEMS = 250; // nr of items (this translates to: consecutive @@ -365,6 +365,11 @@ AddressService.prototype.getAddressUnspentOutputs = function(address, options, c utxoStream.on('data', function(data) { + if(results.length >= MAX_TX_QUERY_LIMIT) { //Max array limit reached, end response + utxoStream.emit('end'); + return; + } + var key = self._encoding.decodeUtxoIndexKey(data.key); var value = self._encoding.decodeUtxoIndexValue(data.value); @@ -551,6 +556,12 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal txIdTransformStream._transform = function(chunk, enc, callback) { var txInfo = self._encoding.decodeAddressIndexKey(chunk); + + if(results.length >= MAX_TX_QUERY_LIMIT) { //Max array limit reached, end response + txIdTransformStream.emit('end'); + return; + } + results.push({ txid: txInfo.txid, height: txInfo.height }); callback(); };