Skip to content

Commit ec001ba

Browse files
author
Dmitry Voronov
committed
Formatting fixed
1 parent 202f5ac commit ec001ba

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/RateLimit.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@ class RateLimit(config: RateLimitConfig) extends Directive0 with Json4sSupport {
4343
override def tapply(f: Unit => Route): Route = {
4444
if (config.enabled) {
4545
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
6255
}
56+
)
57+
if (exists) {
58+
val err = JsonRpcError.RateLimitError(minInterval)
59+
complete((StatusCodes.TooManyRequests, err))
60+
} else {
61+
f.apply(())
6362
}
64-
} else f.apply(())
63+
}
64+
} else f.apply(())
6565
}
6666

6767
}

0 commit comments

Comments
 (0)