Have AuthRegister and AbsoluteRegister cancel each other out

This commit is contained in:
bitfl0wer 2023-04-20 20:11:12 +02:00
parent 897df7adce
commit 4f745c958c
No known key found for this signature in database
GPG Key ID: 84BBB60DF895ABF2
1 changed files with 12 additions and 1 deletions

View File

@ -100,7 +100,7 @@ impl LimitedRequester {
} }
fn can_send_request(&mut self, limit_type: LimitType) -> bool { fn can_send_request(&mut self, limit_type: LimitType) -> bool {
let limits = &self.limits_rate; let limits = &self.limits_rate.clone();
// Check if all of the limits in this vec have at least one remaining request // Check if all of the limits in this vec have at least one remaining request
let constant_limits: Vec<&LimitType> = [ let constant_limits: Vec<&LimitType> = [
&LimitType::Error, &LimitType::Error,
@ -115,6 +115,17 @@ impl LimitedRequester {
if limit.remaining == 0 { if limit.remaining == 0 {
return false; return false;
} }
// AbsoluteRegister and AuthRegister can cancel each other out.
if limit.bucket == LimitType::AbsoluteRegister
&& limits.get(&LimitType::AuthRegister).unwrap().remaining == 0
{
return false;
}
if limit.bucket == LimitType::AuthRegister
&& limits.get(&LimitType::AbsoluteRegister).unwrap().remaining == 0
{
return false;
}
} }
None => return false, None => return false,
} }