Fix integer division in call link ratelimit leak rate

This commit is contained in:
Katherine Yen 2023-05-16 14:34:06 -07:00 committed by GitHub
parent 0889741f34
commit 34d77e73ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -6,6 +6,11 @@
package org.whispersystems.textsecuregcm.limits;
public record RateLimiterConfig(int bucketSize, double leakRatePerMinute) {
public RateLimiterConfig {
if (leakRatePerMinute <= 0) {
throw new IllegalArgumentException("leakRatePerMinute cannot be less than or equal to zero");
}
}
public double leakRatePerMillis() {
return leakRatePerMinute / (60.0 * 1000.0);

View File

@ -74,7 +74,7 @@ public class RateLimiters extends BaseRateLimiters<RateLimiters.For> {
PUSH_CHALLENGE_SUCCESS("pushChallengeSuccess", true, new RateLimiterConfig(2, 2.0 / (60 * 24))),
CREATE_CALL_LINK("createCallLink", false, new RateLimiterConfig(100, 100 / (60 * 24)));
CREATE_CALL_LINK("createCallLink", false, new RateLimiterConfig(100, 100.0 / (60 * 24)));
;
private final String id;