From 4eb3caea00a4286ceaa8fa8a3c2e3cfe77554cd6 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 4 Dec 2015 11:13:34 -0300 Subject: [PATCH] force history limit --- lib/server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index e34d796..a2495b2 100644 --- a/lib/server.js +++ b/lib/server.js @@ -35,6 +35,7 @@ var blockchainExplorerOpts; var messageBroker; var serviceVersion; +var HISTORY_LIMIT = 10; /** * Creates an instance of the Bitcore Wallet Service. @@ -1972,6 +1973,10 @@ WalletService.prototype._normalizeTxHistory = function(txs) { WalletService.prototype.getTxHistory = function(opts, cb) { var self = this; + opts = opts || {}; + opts.limit = (_.isUndefined(opts.limit) ? HISTORY_LIMIT : opts.limit); + if (opts.limit > HISTORY_LIMIT) opts.limit = HISTORY_LIMIT; + function decorate(txs, addresses, proposals) { var indexedAddresses = _.indexBy(addresses, 'address'); @@ -2094,7 +2099,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { }, function(next) { var from = opts.skip || 0; - var to = from + (_.isUndefined(opts.limit) ? 100 : opts.limit); + var to = from + opts.limit; bc.getTransactions(addressStrs, from, to, function(err, txs) { if (err) return cb(err); next(null, self._normalizeTxHistory(txs));