diff --git a/daemon/src/main/java/bisq/daemon/grpc/interceptor/CallRateMeteringInterceptor.java b/daemon/src/main/java/bisq/daemon/grpc/interceptor/CallRateMeteringInterceptor.java index 2f727e9cdc..ab82978f01 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/interceptor/CallRateMeteringInterceptor.java +++ b/daemon/src/main/java/bisq/daemon/grpc/interceptor/CallRateMeteringInterceptor.java @@ -84,11 +84,13 @@ public final class CallRateMeteringInterceptor implements ServerInterceptor { GrpcCallRateMeter rateMeter) { // The derived method name may not be an exact match to CLI's method name. String timeUnitName = StringUtils.chop(rateMeter.getTimeUnit().name().toLowerCase()); - return format("the maximum allowed number of %s calls (%d/%s) has been exceeded by %d calls", + int callCountAboveLimit = rateMeter.getCallsCount() - rateMeter.getAllowedCallsPerTimeUnit(); + return format("the maximum allowed number of %s calls (%d/%s) has been exceeded by %d call%s", methodName.toLowerCase(), rateMeter.getAllowedCallsPerTimeUnit(), timeUnitName, - rateMeter.getCallsCount() - rateMeter.getAllowedCallsPerTimeUnit()); + callCountAboveLimit, + callCountAboveLimit == 1 ? "" : "s"); } private Optional> getRateMeterKV(ServerCall serverCall) { diff --git a/daemon/src/main/java/bisq/daemon/grpc/interceptor/GrpcCallRateMeter.java b/daemon/src/main/java/bisq/daemon/grpc/interceptor/GrpcCallRateMeter.java index 62dbdc9a78..45a07f8897 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/interceptor/GrpcCallRateMeter.java +++ b/daemon/src/main/java/bisq/daemon/grpc/interceptor/GrpcCallRateMeter.java @@ -18,12 +18,12 @@ import static java.lang.String.format; public final class GrpcCallRateMeter { @Getter - private final long allowedCallsPerTimeUnit; + private final int allowedCallsPerTimeUnit; @Getter private final TimeUnit timeUnit; @Getter - private long callsCount = 0; + private int callsCount = 0; @Getter private boolean isRunning; @@ -31,7 +31,7 @@ public final class GrpcCallRateMeter { @Nullable private Timer timer; - public GrpcCallRateMeter(long allowedCallsPerTimeUnit, TimeUnit timeUnit) { + public GrpcCallRateMeter(int allowedCallsPerTimeUnit, TimeUnit timeUnit) { this.allowedCallsPerTimeUnit = allowedCallsPerTimeUnit; this.timeUnit = timeUnit; }