From 831bf0b988216ec9b1657bf548ef3d849e733427 Mon Sep 17 00:00:00 2001 From: Patrick Nagurny Date: Mon, 23 Jan 2017 14:53:27 -0500 Subject: [PATCH] db should only sync after all services are started --- lib/services/db.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/services/db.js b/lib/services/db.js index 92eed429..ecd4299d 100644 --- a/lib/services/db.js +++ b/lib/services/db.js @@ -161,8 +161,9 @@ DB.prototype.start = function(callback) { this.store = levelup(this.dataPath, { db: this.levelupStore, maxOpenFiles: this.maxOpenFiles, keyEncoding: 'binary', valueEncoding: 'binary'}); this.node.services.bitcoind.on('tx', this.transactionHandler.bind(this)); - this.once('ready', function() { - log.info('Bitcoin Database Ready'); + this.node.once('ready', function() { + // start syncing + self.sync(); // Notify that there is a new tip self.node.services.bitcoind.on('tip', function() { @@ -188,8 +189,6 @@ DB.prototype.start = function(callback) { return callback(err); } - self.sync(); - self.emit('ready'); setImmediate(callback); }); });