From aadd336b4cd88a99a1e43ba2e055c40020732833 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Thu, 2 Mar 2017 20:25:20 -0500 Subject: [PATCH] Fixed premature initial sync ending. --- lib/services/db/sync.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/services/db/sync.js b/lib/services/db/sync.js index fccd0310..9456387e 100644 --- a/lib/services/db/sync.js +++ b/lib/services/db/sync.js @@ -18,6 +18,7 @@ function BlockStream(highWaterMark, bitcoind, lastHeight) { this.stopping = false; this.queue = []; this.processing = false; + this.syncing = true; } inherits(BlockStream, Readable); @@ -182,6 +183,7 @@ BlockStream.prototype._process = function() { var self = this; if (!self.syncing) { + return self.push(null); } @@ -215,7 +217,9 @@ BlockStream.prototype._process = function() { for(var i = 0; i < blocks.length; i++) { self.push(blocks[i]); + if (blocks[i].hash === self.bitcoind.tip) { + self.syncing = false; self.emit('synced'); break; @@ -296,8 +300,6 @@ ProcessSerial.prototype._process = function(block, callback) { ProcessConcurrent.prototype._transform = function(block, enc, callback) { var self = this; - //console.log('concurrent', block.__height); - this.lastBlock = block; self.db.getConcurrentBlockOperations(block, true, function(err, operations) {