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')