Merge pull request #403 from braydonf/bug/limit-addresses

Address Service: Limit the number of simultaneous requests
This commit is contained in:
Chris Kleeschulte 2016-02-02 14:25:13 -05:00
commit 6a899e4b9c
2 changed files with 5 additions and 1 deletions

View File

@ -49,6 +49,8 @@ exports.MAX_OUTPUTS_QUERY_LENGTH = 50000;
exports.MAX_HISTORY_QUERY_LENGTH = 100;
// The maximum number of addresses that can be queried at once
exports.MAX_ADDRESSES_QUERY = 10000;
// The maximum number of simultaneous requests
exports.MAX_ADDRESSES_LIMIT = 50;
module.exports = exports;

View File

@ -24,6 +24,7 @@ function AddressHistory(args) {
this.maxHistoryQueryLength = args.options.maxHistoryQueryLength || constants.MAX_HISTORY_QUERY_LENGTH;
this.maxAddressesQuery = args.options.maxAddressesQuery || constants.MAX_ADDRESSES_QUERY;
this.maxAddressesLimit = args.options.maxAddressesLimit || constants.MAX_ADDRESSES_LIMIT;
this.addressStrings = [];
for (var i = 0; i < this.addresses.length; i++) {
@ -89,8 +90,9 @@ AddressHistory.prototype.get = function(callback) {
} else {
var opts = _.clone(this.options);
opts.fullTxList = true;
async.map(
async.mapLimit(
self.addresses,
self.maxAddressesLimit,
function(address, next) {
self.node.services.address.getAddressSummary(address, opts, next);
},