diff --git a/lib/HistoricSync.js b/lib/HistoricSync.js index 826fc05e..180eb101 100644 --- a/lib/HistoricSync.js +++ b/lib/HistoricSync.js @@ -320,6 +320,7 @@ function spec() { var self = this; var lastBlock; + var tip; async.series([ function(cb) { @@ -333,7 +334,6 @@ function spec() { function (cb) { return self.getBlockCount(cb); }, function(cb) { if (!scanOpts.reverse) return cb(); - self.rpc.getBlockHash(self.blockChainHeight, function(err, res) { if (err) return cb(err); lastBlock = res.result; @@ -341,6 +341,17 @@ function spec() { return cb(); }); }, + function(cb) { + if (!scanOpts.reverse) return cb(); + self.sync.bDb.getTip(function(err, res) { + if (err) return cb(err); + tip = res; + + console.log('Old Tip:', tip); + return cb(); + }); + }, + function(cb) { if (scanOpts.upToExisting) { // should be isOrphan = true or null to be more accurate. @@ -378,7 +389,7 @@ function spec() { if (scanOpts.reverse) { start = lastBlock; - end = self.genesis; + end = tip || self.genesis; scanOpts.prev = true; } else {