pub struct RateLimiter { /* private fields */ }Expand description
Rate-limit tracking per peer.
Implementations§
Source§impl RateLimiter
impl RateLimiter
Sourcepub const MAX_TRACKED_PEERS: usize = 4096
pub const MAX_TRACKED_PEERS: usize = 4096
Maximum number of distinct peers tracked in one rate-limit window.
Distinct peer IDs are attacker-controlled at the network boundary. Keep this bounded so a stream of one-shot IDs cannot grow memory without limit before the next window reset.
Sourcepub fn check_and_increment(&mut self, peer: &PeerId) -> Result<()>
pub fn check_and_increment(&mut self, peer: &PeerId) -> Result<()>
Increment the request count for a peer, returning an error if the limit is exceeded.
Trait Implementations§
Source§impl Debug for RateLimiter
impl Debug for RateLimiter
Source§impl Default for RateLimiter
impl Default for RateLimiter
Source§fn default() -> RateLimiter
fn default() -> RateLimiter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RateLimiter
impl RefUnwindSafe for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin for RateLimiter
impl UnwindSafe for RateLimiter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more