Merge pull request #404 from braydonf/lower-limits

Lower and include new concurrency limits
This commit is contained in:
Chris Kleeschulte 2016-02-03 13:17:48 -05:00
commit 8afb2b8669
3 changed files with 11 additions and 2 deletions

View File

@ -50,7 +50,7 @@ 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;
exports.MAX_ADDRESSES_LIMIT = 5;
module.exports = exports;

View File

@ -51,6 +51,7 @@ function DB(options) {
this._setDataPath();
this.maxOpenFiles = options.maxOpenFiles || DB.DEFAULT_MAX_OPEN_FILES;
this.maxTransactionLimit = options.maxTransactionLimit || DB.MAX_TRANSACTION_LIMIT;
this.levelupStore = leveldown;
if (options.store) {
@ -75,6 +76,11 @@ DB.PREFIXES = {
TIP: new Buffer('04', 'hex')
};
// The maximum number of transactions to query at once
// Used for populating previous inputs
DB.MAX_TRANSACTION_LIMIT = 5;
// The default maxiumum number of files open for leveldb
DB.DEFAULT_MAX_OPEN_FILES = 200;
/**

View File

@ -5,6 +5,8 @@ var levelup = require('levelup');
var bitcore = require('bitcore-lib');
var Transaction = bitcore.Transaction;
var MAX_TRANSACTION_LIMIT = 5;
Transaction.prototype.populateInputs = function(db, poolTransactions, callback) {
var self = this;
@ -12,8 +14,9 @@ Transaction.prototype.populateInputs = function(db, poolTransactions, callback)
return setImmediate(callback);
}
async.each(
async.eachLimit(
this.inputs,
db.maxTransactionLimit || MAX_TRANSACTION_LIMIT,
function(input, next) {
self._populateInput(db, input, poolTransactions, next);
},