hotfix for unresponsive header sync
This commit is contained in:
parent
00515c5378
commit
f9e2ed304b
@ -14,6 +14,8 @@ var assert = require('assert');
|
|||||||
var constants = require('../../constants');
|
var constants = require('../../constants');
|
||||||
var bcoin = require('fcoin');
|
var bcoin = require('fcoin');
|
||||||
|
|
||||||
|
const SYNC_CHECK_INTERVAL = 1000 * 60 * 15; //15 mins
|
||||||
|
|
||||||
var HeaderService = function(options) {
|
var HeaderService = function(options) {
|
||||||
|
|
||||||
BaseService.call(this, options);
|
BaseService.call(this, options);
|
||||||
@ -522,6 +524,7 @@ HeaderService.prototype._saveHeaders = function(dbOps, callback) {
|
|||||||
HeaderService.prototype._onHeadersSave = function(callback) {
|
HeaderService.prototype._onHeadersSave = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
self._syncUnresponsive = false; //SZ: got response from peer
|
||||||
self._logProgress();
|
self._logProgress();
|
||||||
|
|
||||||
if (!self._syncComplete()) {
|
if (!self._syncComplete()) {
|
||||||
@ -529,6 +532,8 @@ HeaderService.prototype._onHeadersSave = function(callback) {
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearInterval(self._syncCheckInterval); //SZ: clear the interval check as sync is completed
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -707,6 +712,16 @@ HeaderService.prototype._startSync = function() {
|
|||||||
// common case
|
// common case
|
||||||
if (numNeeded > 0) {
|
if (numNeeded > 0) {
|
||||||
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
|
||||||
|
self._syncUnresponsive = true;
|
||||||
|
self._syncCheckInterval = setInterval(() => {
|
||||||
|
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