From ef296c5ebfa4a6294c484c60360059ec036813d5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 13 Jul 2015 17:14:02 -0300 Subject: [PATCH] rm start/end --- app/controllers/addresses.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/addresses.js b/app/controllers/addresses.js index 16d5d7c..9e03a93 100644 --- a/app/controllers/addresses.js +++ b/app/controllers/addresses.js @@ -127,23 +127,24 @@ exports.multitxs = function(req, res, next) { txs = _.uniq(_.flatten(txs), 'txid'); var nbTxs = txs.length; - if ( _.isUndefined(from) && _.isUndefined(to)) { + if (_.isUndefined(from) && _.isUndefined(to)) { from = 0; to = MAX_BATCH_SIZE; } - - if ( ! _.isUndefined(from) && _.isUndefined(to)) + if (!_.isUndefined(from) && _.isUndefined(to)) to = from + MAX_BATCH_SIZE; - if ( ! _.isUndefined(from) && ! _.isUndefined(to) && to - from > MAX_BATCH_SIZE) + if (!_.isUndefined(from) && !_.isUndefined(to) && to - from > MAX_BATCH_SIZE) to = from + MAX_BATCH_SIZE; + if (from < 0) from = 0; + if (to > nbTxs) tx = nbTxs; + txs.sort(function(a, b) { return (b.ts || b.ts) - (a.ts || a.ts); }); - var start = Math.max(from || 0, 0); - var end = Math.min(to || nbTxs, nbTxs); - txs = txs.slice(start, end); + + txs = txs.slice(from, to); var txIndex = {}; _.each(txs, function(tx) {