From 4d8d9f15a2e1656dc3fa58036500a8cc3cc88b3a Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sat, 22 May 2021 18:53:06 +0530 Subject: [PATCH] Stop the sync Stopping the sync on header service and block service. --- lib/services/block/index.js | 4 ++++ lib/services/header/index.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/services/block/index.js b/lib/services/block/index.js index 73ad6be8..5e314e5f 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -1089,6 +1089,10 @@ BlockService.prototype._startSync = function() { var numNeeded = Math.max(this._header.getLastHeader().height - this._tip.height, 0); + //Ranchimall: stop sync [Changes: adding the following 2 lines] + log.info('RM-BlockService: original numNeeded: ' + numNeeded + '. Resetting to 0') + numNeeded = 0; + //End of changes log.info('Block Service: Gathering: ' + numNeeded + ' block(s) from the peer-to-peer network.'); if (numNeeded > 0) { diff --git a/lib/services/header/index.js b/lib/services/header/index.js index 4f2bb78b..1aab49fd 100644 --- a/lib/services/header/index.js +++ b/lib/services/header/index.js @@ -523,10 +523,12 @@ HeaderService.prototype._onHeadersSave = function(callback) { self._logProgress(); + /* Ranchimall: Stopping the sync [changes: commented the if block] if (!self._syncComplete()) { self._sync(); return callback(); } + END of changes */ self._endHeaderSubscription(); // we don't need headers any more self._startBlockSubscription(); // we need new blocks coming tu us aynchronuously @@ -703,6 +705,11 @@ HeaderService.prototype._startSync = function() { self._reorging = false; var numNeeded = Math.max(self._bestHeight, self._originalHeight) - self._tip.height; + //Ranchimall: stopping sync [Changes: adding the following 3 lines + log.info('RM-HeaderService: self._tip.height: ' + self._tip.height) + log.info('RM-HeaderService: original numNeeded: ' + numNeeded +'. Resetting to 0') + numNeeded = 0; + //End of changes // common case if (numNeeded > 0) { log.info('Header Service: Gathering: ' + numNeeded + ' ' + 'header(s) from the peer-to-peer network.');