Need to fix slp tier as 40

This commit is contained in:
Chris Troutner
2020-02-07 00:29:39 -08:00
parent 4c80776754
commit 97e49180e3
2 changed files with 116 additions and 6 deletions
+13 -3
View File
@@ -37,6 +37,7 @@ class RateLimits {
constructor() {
_this = this
this.jwt = jwt
this.rateLimiter = new RateLimiterRedis(rateLimitOptions)
}
@@ -259,7 +260,11 @@ class RateLimits {
const pemPublicKey = keyEncoder.encodePublic(publicKey, "raw", "pem")
// Validate the JWT token.
decoded = jwt.verify(req.locals.jwtToken, pemPublicKey, jwtOptions)
decoded = _this.jwt.verify(
req.locals.jwtToken,
pemPublicKey,
jwtOptions
)
// console.log(`decoded: ${JSON.stringify(decoded, null, 2)}`)
userId = decoded.id
@@ -289,7 +294,7 @@ class RateLimits {
await _this.rateLimiter.consume(key, pointsToConsume)
} catch (err) {
console.log(`err: `, err)
// console.log(`err: `, err)
// Rate limited was triggered
res.status(429) // https://github.com/Bitcoin-com/rest.bitcoin.com/issues/330
@@ -336,9 +341,14 @@ class RateLimits {
else retVal = 10
}
// Full node tier
else if (apiLevel >= 10) {
retVal = 1
}
// Free tier, full node only.
else {
retVal = 1
retVal = 10
}
}