Update index.js
This commit is contained in:
parent
635c344268
commit
def559a86a
@ -16,7 +16,7 @@ var utils = require('../../utils');
|
||||
var LRU = require('lru-cache');
|
||||
var XXHash = require('xxhash');
|
||||
|
||||
const MAX_TX_QUERY_LIMIT = 1000;
|
||||
const MAX_TX_QUERY_LIMIT = 100;
|
||||
|
||||
// See rationale about this cache at function getTxList(next)
|
||||
const TXID_LIST_CACHE_ITEMS = 250; // nr of items (this translates to: consecutive
|
||||
@ -208,7 +208,8 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream
|
||||
return log.error(err);
|
||||
|
||||
if(!options.txNotNeeded && results.items.length < MAX_TX_QUERY_LIMIT)
|
||||
results.items.push(tx);
|
||||
if(!results.items.some(x => x.txid === tx.txid)) //push only if tx not already in array
|
||||
results.items.push(tx);
|
||||
|
||||
streamer(null, tx);
|
||||
|
||||
@ -220,6 +221,9 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
//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()));
|
||||
|
||||
//TODO: sorting of tx list (results.items)
|
||||
callback(null, results);
|
||||
|
||||
@ -475,7 +479,7 @@ AddressService.prototype._aggregateAddressSummaryResult = function (tx, address,
|
||||
result.transactions = [];
|
||||
}
|
||||
let txid = tx.txid();
|
||||
if(!result.transactions.includes(txid)) //push txid only if its not in the array
|
||||
if(!result.transactions.includes(txid) && result.transactions.length < MAX_TX_QUERY_LIMIT) //push txid only if its not in the array (list limit not maxed out)
|
||||
result.transactions.push(txid);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user