Skip to content

Commit

Permalink
chore: Split Config functions per reservation and circuit-src
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Jul 29, 2023
1 parent 6932b3f commit 2dc4652
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions protocols/relay/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,31 @@ pub struct Config {
}

impl Config {
pub fn per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self {
pub fn reservation_rate_per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.reservation_rate_limiters
.push(rate_limiter::new_per_peer(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn circuit_src_per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.circuit_src_rate_limiters
.push(rate_limiter::new_per_peer(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self {
pub fn reservation_rate_per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.reservation_rate_limiters
.push(rate_limiter::new_per_ip(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn circuit_src_per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.circuit_src_rate_limiters
.push(rate_limiter::new_per_ip(
rate_limiter::GenericRateLimiterConfig { limit, interval },
Expand Down

0 comments on commit 2dc4652

Please sign in to comment.