better block_total accounting
This commit is contained in:
parent
4442497638
commit
82beb27a3c
|
@ -70,7 +70,7 @@ function spec() {
|
|||
},
|
||||
//show some (inacurate) status
|
||||
function(c) {
|
||||
if (that.block_count++ % 1000 === 0) {
|
||||
if (that.block_count % 1000 === 1) {
|
||||
progress_bar('sync status:', that.block_count, that.block_total);
|
||||
}
|
||||
return c();
|
||||
|
@ -91,7 +91,6 @@ function spec() {
|
|||
//store it
|
||||
function(c) {
|
||||
if (existed) return c();
|
||||
|
||||
that.sync.storeBlock(blockInfo.result, function(err) {
|
||||
existed = err && err.toString().match(/E11000/);
|
||||
if (err && ! existed) return c(err);
|
||||
|
@ -112,7 +111,7 @@ function spec() {
|
|||
function (err){
|
||||
|
||||
if (opts.uptoexisting && existed) {
|
||||
p('DONE. Found existing block: %s ', blockHash);
|
||||
p('DONE. Found existing block: ', blockHash);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
|
@ -120,6 +119,7 @@ function spec() {
|
|||
p('ERROR: @%s: %s [count: block_count: %d]', blockHash, err, that.block_count);
|
||||
|
||||
if (blockInfo && blockInfo.result) {
|
||||
block_total++;
|
||||
if (opts.prev && blockInfo.result.previousblockhash) {
|
||||
return that.getPrevNextBlock(blockInfo.result.previousblockhash, blockEnd, opts, cb);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ function spec() {
|
|||
},
|
||||
function(cb) {
|
||||
that.rpc.getInfo(function(err, res) {
|
||||
if (err) cb(err);
|
||||
if (err) return cb(err);
|
||||
|
||||
that.block_total = res.result.blocks;
|
||||
return cb();
|
||||
|
@ -188,7 +188,7 @@ function spec() {
|
|||
if (!opts.reverse) return cb();
|
||||
|
||||
that.rpc.getBlockCount(function(err, res) {
|
||||
if (err) cb(err);
|
||||
if (err) return cb(err);
|
||||
block_height = res.result;
|
||||
return cb();
|
||||
});
|
||||
|
@ -197,7 +197,7 @@ function spec() {
|
|||
if (!opts.reverse) return cb();
|
||||
|
||||
that.rpc.getBlockHash(block_height, function(err, res) {
|
||||
if (err) cb(err);
|
||||
if (err) return cb(err);
|
||||
|
||||
block_best = res.result;
|
||||
return cb();
|
||||
|
|
|
@ -14,6 +14,7 @@ var async = require('async');
|
|||
program
|
||||
.version(SYNC_VERSION)
|
||||
.option('-N --network [livenet]', 'Set bitcoin network [testnet]', 'testnet')
|
||||
.option('-S --smart', 'genesis stored? uptoexisting = 1', 1)
|
||||
.option('-D --destroy', 'Remove current DB (and start from there)', 0)
|
||||
.option('-R --reverse', 'Sync backwards', 0)
|
||||
.option('-U --uptoexisting', 'Sync only until an existing block is found', 0)
|
||||
|
@ -37,6 +38,7 @@ async.series([
|
|||
destroy: program.destroy,
|
||||
reverse: program.reverse,
|
||||
uptoexisting: program.uptoexisting,
|
||||
smart: program.smart,
|
||||
}, function(err, count) {
|
||||
if (err) {
|
||||
console.log('CRITICAL ERROR: ', err);
|
||||
|
|
Loading…
Reference in New Issue