Adding test case and logging

This commit is contained in:
sairajzero 2023-01-17 22:11:11 +05:30
parent ba08acb6ae
commit 1fa3d45445

View File

@ -14,6 +14,7 @@ var _ = require('lodash');
var LRU = require('lru-cache');
const MAX_IGNORED_BLOCK = 32; //Maximum ignored block allowed before trigging sync again
var __TestingCount = 5;
var BlockService = function(options) {
@ -936,11 +937,17 @@ BlockService.prototype._processBlock = function(block, callback) {
log.debug('Block Service: new block: ' + block.rhash());
//Manually ignore a block for testing
__TestingCount--;
if(__TestingCount === 0)
return console.debug("TESTING: Ignored block");
// common case
if (!self._detectReorg(block)) {
return self._saveBlock(block, callback);
}
console.debug("TESTING: _ignoredBlockCount=", self._ignoredBlockCount)
//SZ: count the ignored blocks. if many blocks ignored, trigger sync process
if(self._ignoredBlockCount < MAX_IGNORED_BLOCK)
self._ignoredBlockCount++;