File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed
src/main/scala/io/iohk/ethereum/jsonrpc/server/http Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -43,25 +43,25 @@ class RateLimit(config: RateLimitConfig) extends Directive0 with Json4sSupport {
43
43
override def tapply (f : Unit => Route ): Route = {
44
44
if (config.enabled) {
45
45
val minInterval = config.minRequestInterval.toSeconds
46
- extractClientIP { ip =>
47
- var exists = true
48
- // We can avoid using var
49
- // But in this case we access our LRU twice.
50
- lru.get(
51
- ip,
52
- () => {
53
- exists = false
54
- NotUsed
55
- }
56
- )
57
- if (exists) {
58
- val err = JsonRpcError .RateLimitError (minInterval)
59
- complete((StatusCodes .TooManyRequests , err))
60
- } else {
61
- f.apply(())
46
+ extractClientIP { ip =>
47
+ var exists = true
48
+ // We can avoid using var
49
+ // But in this case we access our LRU twice.
50
+ lru.get(
51
+ ip,
52
+ () => {
53
+ exists = false
54
+ NotUsed
62
55
}
56
+ )
57
+ if (exists) {
58
+ val err = JsonRpcError .RateLimitError (minInterval)
59
+ complete((StatusCodes .TooManyRequests , err))
60
+ } else {
61
+ f.apply(())
63
62
}
64
- } else f.apply(())
63
+ }
64
+ } else f.apply(())
65
65
}
66
66
67
67
}
You can’t perform that action at this time.
0 commit comments