increment errors score

This commit is contained in:
smart_ex 2022-04-08 20:29:37 +10:00 committed by Danil Kovtonyuk
parent cfcf1c8677
commit 95c6dc23c6
8 changed files with 36 additions and 10 deletions

View file

@ -125,6 +125,20 @@ class RelayerError extends Error {
}
}
const logRelayerError = async (redis, e) => {
await redis.zadd('errors', 'INCR', 1, e.message)
}
const readRelayerErrors = async redis => {
const set = await redis.zrevrange('errors', 0, -1, 'WITHSCORES')
const errors = []
while (set.length) {
const [message, score] = set.splice(0, 2)
errors.push({ message, score })
}
return errors
}
module.exports = {
getInstance,
setSafeInterval,
@ -140,4 +154,6 @@ module.exports = {
BN,
isAddress,
RelayerError,
logRelayerError,
readRelayerErrors,
}