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();
|
||||
}
|
||||
|
||||
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._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.');
|
||||
|
||||
//SZ: Adding interval check for sync with peer is responsive or not
|
||||
self._syncUnresponsive = true;
|
||||
self._syncCheckInterval = setInterval(() => {
|
||||
if(self._syncUnresponsive)
|
||||
self._sync();
|
||||
else //reset unresponsive as true
|
||||
self._syncUnresponsive = true;
|
||||
}, SYNC_CHECK_INTERVAL);
|
||||
//(only if fcoin is started by flocore)
|
||||
if(self._p2p._bcoin){
|
||||
self._syncUnresponsive = true;
|
||||
self._syncCheckInterval = setInterval(() => {
|
||||
//check the best height
|
||||
if(self._bestHeight < self._p2p._bcoin._bcoin.pool.chain.height)
|
||||
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();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user