scaffold: remove outdated logging of db service sync status
This commit is contained in:
parent
271dcd8902
commit
ea792b692f
@ -49,9 +49,6 @@ function start(options) {
|
||||
|
||||
var node = new BitcoreNode(fullConfig);
|
||||
|
||||
// set up the event handlers for logging sync information
|
||||
start.registerSyncHandlers(node);
|
||||
|
||||
// setup handlers for uncaught exceptions and ctrl+c
|
||||
start.registerExitHandlers(process, node);
|
||||
|
||||
@ -153,50 +150,6 @@ function setupServices(req, servicesPath, config) {
|
||||
return services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register event handlers to log the current db sync status.
|
||||
* @param {Node} node
|
||||
*/
|
||||
function registerSyncHandlers(node, delay) {
|
||||
|
||||
delay = delay || 10000;
|
||||
var interval = false;
|
||||
var count = 0;
|
||||
|
||||
function logSyncStatus() {
|
||||
log.info(
|
||||
'Database Sync Status: Tip:', node.services.db.tip.hash,
|
||||
'Height:', node.services.db.tip.__height,
|
||||
'Rate:', count/10, 'blocks per second'
|
||||
);
|
||||
}
|
||||
|
||||
node.on('ready', function() {
|
||||
|
||||
if (node.services.db) {
|
||||
node.on('synced', function() {
|
||||
clearInterval(interval);
|
||||
logSyncStatus();
|
||||
});
|
||||
node.services.db.on('addblock', function() {
|
||||
count++;
|
||||
// Initialize logging if not already instantiated
|
||||
if (!interval) {
|
||||
interval = setInterval(function() {
|
||||
logSyncStatus();
|
||||
count = 0;
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
node.on('stopping', function() {
|
||||
clearInterval(interval);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Will shutdown a node and then the process
|
||||
* @param {Object} _process - The Node.js process object
|
||||
@ -260,6 +213,5 @@ function registerExitHandlers(_process, node) {
|
||||
module.exports = start;
|
||||
module.exports.registerExitHandlers = registerExitHandlers;
|
||||
module.exports.exitHandler = exitHandler;
|
||||
module.exports.registerSyncHandlers = registerSyncHandlers;
|
||||
module.exports.setupServices = setupServices;
|
||||
module.exports.cleanShutdown = cleanShutdown;
|
||||
|
||||
@ -96,34 +96,6 @@ describe('#start', function() {
|
||||
}).should.throw('Could not load service');
|
||||
});
|
||||
});
|
||||
describe('#registerSyncHandlers', function() {
|
||||
it('will log the sync status at an interval', function(done) {
|
||||
var log = {
|
||||
info: sinon.stub()
|
||||
};
|
||||
var registerSyncHandlers = proxyquire('../../lib/scaffold/start', {
|
||||
'../': {
|
||||
log: log
|
||||
}
|
||||
}).registerSyncHandlers;
|
||||
var node = new EventEmitter();
|
||||
node.services = {
|
||||
db: new EventEmitter()
|
||||
};
|
||||
node.services.db.tip = {
|
||||
hash: 'hash',
|
||||
__height: 10
|
||||
};
|
||||
registerSyncHandlers(node, 10);
|
||||
node.emit('ready');
|
||||
node.services.db.emit('addblock');
|
||||
setTimeout(function() {
|
||||
node.emit('synced');
|
||||
log.info.callCount.should.be.within(3, 4);
|
||||
done();
|
||||
}, 35);
|
||||
});
|
||||
});
|
||||
describe('#cleanShutdown', function() {
|
||||
it('will call node stop and process exit', function() {
|
||||
var log = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user