From be831a4be19e5d7c37ed43b855a3ee05bed39ec8 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 18 Oct 2023 17:38:44 +0300 Subject: [PATCH] Fix validator info reloading --- src/server.ts | 15 +++++++++++---- src/services/validatorStaking/validatorsInfo.ts | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/server.ts b/src/server.ts index 0f5a149..18510d9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,7 +6,9 @@ import { newLogger } from '@subsocial/utils' import { createRoutes } from './routes' import { Connections } from './connections' -import { getOrCreateRedisCache } from './cache/redisCache'; +import { getOrCreateRedisCache } from './cache/redisCache' +import { validatorStakingInfoCache } from './services/validatorStaking' +import { relayChains } from './services/crowdloan/types' require('dotenv').config() @@ -79,7 +81,12 @@ export const startHttpServer = (apis: Connections) => { redis?.on('connect', async () => { log.info('Redis connected') redisCache.setIsConnectionClosed(false) - await redisCache.checkConnection({ showLogs: true }) + + await redisCache.checkConnection({ showLogs: true }); + + relayChains.forEach((network) => { + validatorStakingInfoCache.set(network, undefined) + }) }) // for parsing multipart/form-data @@ -91,6 +98,6 @@ export const startHttpServer = (apis: Connections) => { } process.on('unhandledRejection', (reason, promise) => { - console.log('Unhandled Rejection at:', promise, 'reason:', reason); + console.log('Unhandled Rejection at:', promise, 'reason:', reason) // Application specific logging, throwing an error, or other logic here -}); +}) diff --git a/src/services/validatorStaking/validatorsInfo.ts b/src/services/validatorStaking/validatorsInfo.ts index d77af85..4ccbd02 100644 --- a/src/services/validatorStaking/validatorsInfo.ts +++ b/src/services/validatorStaking/validatorsInfo.ts @@ -10,7 +10,7 @@ import { Connections } from '../../connections' import { relayChains } from '../crowdloan/types' import { isEmptyObj, newLogger } from '@subsocial/utils' -const validatorStakingInfoCache = new Cache('validator-staking-info', FIVE_MINUTES) +export const validatorStakingInfoCache = new Cache('validator-staking-info', FIVE_MINUTES) const log = newLogger('ValidatorStakingInfo')