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 LRU = require('lru-cache');
|
||||||
var XXHash = require('xxhash');
|
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)
|
// See rationale about this cache at function getTxList(next)
|
||||||
const TXID_LIST_CACHE_ITEMS = 250; // nr of items (this translates to: consecutive
|
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);
|
return log.error(err);
|
||||||
|
|
||||||
if(!options.txNotNeeded && results.items.length < MAX_TX_QUERY_LIMIT)
|
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);
|
streamer(null, tx);
|
||||||
|
|
||||||
@ -220,6 +221,9 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream
|
|||||||
return callback(err);
|
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)
|
//TODO: sorting of tx list (results.items)
|
||||||
callback(null, results);
|
callback(null, results);
|
||||||
|
|
||||||
@ -475,7 +479,7 @@ AddressService.prototype._aggregateAddressSummaryResult = function (tx, address,
|
|||||||
result.transactions = [];
|
result.transactions = [];
|
||||||
}
|
}
|
||||||
let txid = tx.txid();
|
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);
|
result.transactions.push(txid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user