hotfix: best header not updating for prev fix
- updated header service best header from fcoin node directly. - set interval check only if fcoin is started by flocore (else header best height ll not get updated and sync complete incorrectly)
This commit is contained in:
parent
b831cbce7e
commit
ece347c825
@ -532,7 +532,9 @@ HeaderService.prototype._onHeadersSave = function(callback) {
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInterval(self._syncCheckInterval); //SZ: clear the interval check as sync is completed
|
//SZ: clear the interval check as sync is completed
|
||||||
|
if(self._syncCheckInterval)
|
||||||
|
clearInterval(self._syncCheckInterval);
|
||||||
|
|
||||||
self._endHeaderSubscription(); // we don't need headers any more
|
self._endHeaderSubscription(); // we don't need headers any more
|
||||||
self._startBlockSubscription(); // we need new blocks coming tu us aynchronuously
|
self._startBlockSubscription(); // we need new blocks coming tu us aynchronuously
|
||||||
@ -714,13 +716,20 @@ HeaderService.prototype._startSync = function() {
|
|||||||
log.info('Header Service: Gathering: ' + numNeeded + ' ' + 'header(s) from the peer-to-peer network.');
|
log.info('Header Service: Gathering: ' + numNeeded + ' ' + 'header(s) from the peer-to-peer network.');
|
||||||
|
|
||||||
//SZ: Adding interval check for sync with peer is responsive or not
|
//SZ: Adding interval check for sync with peer is responsive or not
|
||||||
self._syncUnresponsive = true;
|
//(only if fcoin is started by flocore)
|
||||||
self._syncCheckInterval = setInterval(() => {
|
if(self._p2p._bcoin){
|
||||||
if(self._syncUnresponsive)
|
self._syncUnresponsive = true;
|
||||||
self._sync();
|
self._syncCheckInterval = setInterval(() => {
|
||||||
else //reset unresponsive as true
|
//check the best height
|
||||||
self._syncUnresponsive = true;
|
if(self._bestHeight < self._p2p._bcoin._bcoin.pool.chain.height)
|
||||||
}, SYNC_CHECK_INTERVAL);
|
self._bestHeight = self._p2p._bcoin._bcoin.pool.chain.height;
|
||||||
|
//call sync again if unresponsive
|
||||||
|
if(self._syncUnresponsive)
|
||||||
|
self._sync();
|
||||||
|
else //reset unresponsive as true
|
||||||
|
self._syncUnresponsive = true;
|
||||||
|
}, SYNC_CHECK_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
return self._sync();
|
return self._sync();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user