diff --git a/lib/Sync.js b/lib/Sync.js index 92b89afa..2e425ba1 100644 --- a/lib/Sync.js +++ b/lib/Sync.js @@ -293,6 +293,7 @@ function spec() { var retry_secs = 2; var block_best; + var block_height; this.db.once('open', function() { async.series([ @@ -328,10 +329,20 @@ function spec() { return cb(); }); }, + // We are not using getBestBlockHash, because is not available in all clients function(cb) { if (!opts.reverse) return cb(); - that.rpc.getBestBlockHash(function(err, res) { + that.rpc.getBlockCount(function(err, res) { + if (err) cb(err); + block_height = res.result; + return cb(); + }); + }, + function(cb) { + if (!opts.reverse) return cb(); + + that.rpc.getBlockHash(block_height, function(err, res) { if (err) cb(err); block_best = res.result;