Merge pull request #5 from ranchimall/dev2

hotfix
This commit is contained in:
Sai Raj 2023-01-15 00:05:27 +05:30 committed by GitHub
commit 836f2e1f84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ coverage/*
**/*.config
**/*.creator
*.log
*.tmp
.DS_Store
bin/florincoin*
bin/SHA256SUMS.asc

View File

@ -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();
}