force history limit

This commit is contained in:
Matias Alejo Garcia 2015-12-04 11:13:34 -03:00
parent 611b5e53d3
commit 4eb3caea00
1 changed files with 6 additions and 1 deletions

View File

@ -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));