From 951b368f0b931b79b6ea2483cb5ca952fa3a936e Mon Sep 17 00:00:00 2001 From: Hemulin <> Date: Sun, 1 Jun 2025 01:13:53 +0300 Subject: [PATCH 1/2] Log commenting --- api/src/ol/validators/validators.service.ts | 16 ++++++++-------- api/src/redis/redis.service.ts | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/api/src/ol/validators/validators.service.ts b/api/src/ol/validators/validators.service.ts index 17074e6e..def70d79 100644 --- a/api/src/ol/validators/validators.service.ts +++ b/api/src/ol/validators/validators.service.ts @@ -64,23 +64,23 @@ export class ValidatorsService { if (this.cacheEnabled) { const cachedValidators = await this.getFromCache(VALIDATORS_CACHE_KEY); if (cachedValidators) { - this.logger.debug('Returning cached validators') - this.logger.debug(`Read this data from cache: ${JSON.stringify(cachedValidators).slice(0, 200)}`) + // this.logger.debug('Returning cached validators') + // this.logger.debug(`Read this data from cache: ${JSON.stringify(cachedValidators).slice(0, 200)}`) return cachedValidators; } } const validators = await this.queryValidators(); await this.setCache(VALIDATORS_CACHE_KEY, validators); - this.logger.debug('Stored validators in cache') - this.logger.debug(`This data written back: ${JSON.stringify(validators).slice(0, 200)}`) + // this.logger.debug('Stored validators in cache') + // this.logger.debug(`This data written back: ${JSON.stringify(validators).slice(0, 200)}`) return validators; } public async getValidatorsHandlers(): Promise> { if (this.cacheEnabled) { - this.logger.debug('Cache is enabled') + // this.logger.debug('Cache is enabled') const cacheHandlersString = await this.getFromCache(VALIDATORS_HANDLERS_CACHE_KEY); // NOTE: cacheHandlersString is NOT a string (it is an Object) let result:Map = new Map([['bad', 'data']]); @@ -90,19 +90,19 @@ export class ValidatorsService { } else { result = new Map(); } - this.logger.debug(`returning handles map with ${result.size} entries`) + // this.logger.debug(`returning handles map with ${result.size} entries`) return result; } let handlers = new Map(); try { handlers = await this.loadValidatorHandles(); - this.logger.debug(`Loaded validator handles: ${handlers}, ${JSON.stringify(handlers)}`) + // this.logger.debug(`Loaded validator handles: ${handlers}, ${JSON.stringify(handlers)}`) } catch (error) { this.logger.error('Error loading validators handlers', error); } finally { const obj = Object.fromEntries(handlers); - this.logger.debug(`Storing validator handles: ${obj}, ${JSON.stringify(obj)}`) + // this.logger.debug(`Storing validator handles: ${obj}, ${JSON.stringify(obj)}`) await redisClient.set(VALIDATORS_HANDLERS_CACHE_KEY, JSON.stringify(obj)); this.logger.log('Validators handlers cache updated'); } diff --git a/api/src/redis/redis.service.ts b/api/src/redis/redis.service.ts index a7471533..bf492619 100644 --- a/api/src/redis/redis.service.ts +++ b/api/src/redis/redis.service.ts @@ -18,7 +18,7 @@ export function createRedisConnectionOptions(configService: ConfigService): Conn // BullMQ specific settings for reliability enableReadyCheck: true, retryStrategy: (times) => { - // retry strategy + // conservative retry strategy const delay = Math.min(Math.pow(2, times) * 500, 30000); // Start with shorter delays if (times > 50) { logger.warn(`Redis retry attempts exceeding 50, consider checking server status`); @@ -36,12 +36,12 @@ export class SafeRedisClient { private connected = false; private connecting = false; private readonly maxRetries = 3; - private readonly operationTimeout = 5000; // 5 seconds + private readonly operationTimeout = 5000; // 5 seconds timeout for operations constructor(private readonly configService: ConfigService) { const host = this.configService.get('REDIS_HOST') || 'localhost'; const port = parseInt(this.configService.get('REDIS_PORT') || '6379', 10); - const password = this.configService.get('REDIS_PASSWORD'); + const password = this.configService.get('REDIS_PASSWORD'); // Get password from env if set this.logger.log(`Initializing Redis client for ${host}:${port}`); @@ -49,11 +49,11 @@ export class SafeRedisClient { socket: { host, port, - connectTimeout: 10000, // 10 seconds + connectTimeout: 10000, // 10 seconds connect timeout reconnectStrategy: (retries) => { if (retries > 10) { - // After 5 retries, slow down significantly - const delay = Math.min(5000 + (retries - 5) * 1000, 30000); + // After 10 retries, slow down significantly + const delay = Math.min(5000 + (retries - 10) * 1000, 30000); this.logger.log(`Redis reconnecting in ${delay}ms (attempt ${retries})`); return delay; } @@ -216,7 +216,7 @@ export class SafeRedisClient { } } -// Singleton instance +// Create a Singleton instance export const redisClient = new SafeRedisClient(new ConfigService()); // Export connection options for BullMQ - this should be used in all queue registrations From 27d367f0f421ffc96edb92675953802cdbfc3c43 Mon Sep 17 00:00:00 2001 From: Yotam Katznelson Date: Mon, 2 Jun 2025 18:15:08 +0300 Subject: [PATCH 2/2] Removed forgotten olfyi reference --- api/src/stats/services/accounts.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/stats/services/accounts.service.ts b/api/src/stats/services/accounts.service.ts index 6c62ba3b..c3e54aa6 100644 --- a/api/src/stats/services/accounts.service.ts +++ b/api/src/stats/services/accounts.service.ts @@ -16,7 +16,7 @@ export class AccountsService { SELECT version, address - FROM olfyi.coin_balance + FROM coin_balance WHERE coin_module = 'libra_coin' ORDER BY version ASC `;