scaffold: remove outdated logging of db service sync status

This commit is contained in:
Braydon Fuller 2016-04-27 12:00:47 -04:00
parent 271dcd8902
commit ea792b692f
2 changed files with 0 additions and 76 deletions

View File

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

View File

@ -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 = {