recover from race condition in interrupted sync
This commit is contained in:
parent
fbe16eda9f
commit
ed787d58cb
|
@ -238,22 +238,32 @@ function spec() {
|
|||
function(err) {
|
||||
if (err) return next(err);
|
||||
var ret = false;
|
||||
if ( self.blockChainHeight === blockInfo.height ||
|
||||
blockInfo.confirmations > 0) {
|
||||
if ( self.blockChainHeight === blockInfo.height || // Still the tip
|
||||
blockInfo.confirmations > 0) { // Or is confirmed
|
||||
ret = false;
|
||||
}
|
||||
else {
|
||||
oldtip = tip;
|
||||
tip = blockInfo.previousblockhash;
|
||||
assert(tip);
|
||||
p('Previous TIP is now orphan. Back to:' + tip);
|
||||
p('Previous TIP is now orphan.');
|
||||
if (tip) {
|
||||
p('\tGoing back to:' + tip);
|
||||
ret = true;
|
||||
}
|
||||
else {
|
||||
p('\tNo able to recover last tip. A Total resync is needed.');
|
||||
tip = self.genesis;
|
||||
self.needResync = 1;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
function(err) {
|
||||
self.startBlock = tip;
|
||||
if (!self.needResync) {
|
||||
p('Resuming sync from block:'+tip);
|
||||
}
|
||||
return next(err);
|
||||
}
|
||||
);
|
||||
|
@ -354,15 +364,22 @@ function spec() {
|
|||
function(s_c) {
|
||||
self.checkNetworkSettings(s_c);
|
||||
},
|
||||
function(s_c) {
|
||||
self.updateConnectedCountDB(s_c);
|
||||
},
|
||||
function(s_c) {
|
||||
self.updateBlockChainHeight(s_c);
|
||||
},
|
||||
function(s_c) {
|
||||
self.updateStartBlock(s_c);
|
||||
},
|
||||
function(s_c) {
|
||||
if (self.needResync) {
|
||||
self.needResync=0;
|
||||
self.sync.destroy(s_c);
|
||||
}
|
||||
else s_c();
|
||||
},
|
||||
function(s_c) {
|
||||
self.updateConnectedCountDB(s_c);
|
||||
},
|
||||
function(s_c) {
|
||||
self.prepareFileSync(opts, s_c);
|
||||
},
|
||||
|
|
|
@ -673,7 +673,6 @@ isspent
|
|||
|
||||
var k = FROM_BLK_PREFIX + hash;
|
||||
var k2 = IN_BLK_PREFIX;
|
||||
// This is slow, but prevent us to create a new block->tx index.
|
||||
db.createReadStream({
|
||||
start: k,
|
||||
end: k + '~'
|
||||
|
|
Loading…
Reference in New Issue