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); }); });