Skip to content

Commit

Permalink
Fix validator info reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Oct 18, 2023
1 parent d0d81f7 commit be831a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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
});
})
2 changes: 1 addition & 1 deletion src/services/validatorStaking/validatorsInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Connections } from '../../connections'
import { relayChains } from '../crowdloan/types'
import { isEmptyObj, newLogger } from '@subsocial/utils'

const validatorStakingInfoCache = new Cache<any>('validator-staking-info', FIVE_MINUTES)
export const validatorStakingInfoCache = new Cache<any>('validator-staking-info', FIVE_MINUTES)

const log = newLogger('ValidatorStakingInfo')

Expand Down

0 comments on commit be831a4

Please sign in to comment.