Merge pull request #3 from kleetus/feature/walletIndex

Small fixes for service requiring and warnings.
This commit is contained in:
Patrick Nagurny 2017-01-11 10:32:24 -05:00 committed by GitHub
commit ea7eb52e7c
3 changed files with 28 additions and 12 deletions

View File

@ -4,6 +4,7 @@ var path = require('path');
var BitcoreNode = require('../node');
var index = require('../');
var bitcore = require('bitcore-lib');
var fs = require('fs');
var _ = bitcore.deps._;
var log = index.log;
var shuttingDown = false;
@ -135,17 +136,22 @@ function checkService(service) {
function loadModule(req, service) {
try {
// first try in the built-in bitcore-node services directory
service.module = req(path.resolve(__dirname, '../services/' + service.name));
} catch(e) {
console.log(e);
// check if the package.json specifies a specific file to use
var servicePackage = req(service.name + '/package.json');
var serviceModule = service.name;
if (servicePackage.bitcoreNode) {
serviceModule = service.name + '/' + servicePackage.bitcoreNode;
var serviceFile = path.resolve(__dirname, '../services/' + service.name);
if (fs.existsSync(serviceFile + '.js')) {
// if the file exists, we can require it, then if there is a problem, catch and display the error
service.module = req(serviceFile);
} else {
// check if the package.json specifies a specific file to use
var servicePackage = req(service.name + '/package.json');
var serviceModule = service.name;
if (servicePackage.bitcoreNode) {
serviceModule = service.name + '/' + servicePackage.bitcoreNode;
}
service.module = req(serviceModule);
}
service.module = req(serviceModule);
} catch(e) {
log.error(e.stack);
process.exit(-1);
}
}

View File

@ -76,6 +76,7 @@ Bitcoin.DEFAULT_TRY_ALL_INTERVAL = 1000;
Bitcoin.DEFAULT_REINDEX_INTERVAL = 10000;
Bitcoin.DEFAULT_START_RETRY_INTERVAL = 5000;
Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL = 15000;
Bitcoin.DEFAULT_ZMQ_DELAY_WARNING_MULTIPLIER = 5;
Bitcoin.DEFAULT_TRANSACTION_CONCURRENCY = 5;
Bitcoin.DEFAULT_CONFIG_SETTINGS = {
server: 1,
@ -114,6 +115,10 @@ Bitcoin.prototype._initDefaults = function(options) {
// sync progress level when zmq subscribes to events
this.zmqSubscribeProgress = options.zmqSubscribeProgress || Bitcoin.DEFAULT_ZMQ_SUBSCRIBE_PROGRESS;
// set the zmq delay warning multiplier
this.zmqDelayWarningMultiplier = options.zmqDelayWarningMultiplier || Bitcoin.DEFAULT_ZMQ_DELAY_WARNING_MULTIPLIER;
this.zmqDelayWarningMultiplierCouunt = 0;
};
Bitcoin.prototype._initCaches = function() {
@ -726,7 +731,10 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) {
});
node.zmqSubSocket.on('connect_delay', function(fd, endPoint) {
log.warn('ZMQ connection delay:', endPoint);
if (this.zmqDelayWarningMultiplierCouunt++ >= this.zmqDelayWarningMultiplier) {
log.warn('ZMQ connection delay:', endPoint);
this.zmqDelayWarningMultiplierCouunt = 0;
}
});
node.zmqSubSocket.on('disconnect', function(fd, endPoint) {
@ -740,7 +748,8 @@ Bitcoin.prototype._initZmqSubSocket = function(node, zmqUrl) {
}, 5000);
});
node.zmqSubSocket.monitor(500, 0);
//monitors are polling and not event-driven
node.zmqSubSocket.monitor(100, 0);
node.zmqSubSocket.connect(zmqUrl);
};

View File

@ -55,6 +55,7 @@
"leveldown": "bitpay/leveldown#bitpay-1.4.4",
"levelup": "^1.3.1",
"liftoff": "^2.2.0",
"lmdb": "rvagg/lmdb#5ad819f77714925248dfecb0ba2174080dba949f",
"lru-cache": "^4.0.1",
"memdown": "^1.0.0",
"mkdirp": "0.5.0",