Expand description
Adaptive rate limiting with dynamic adjustments based on peer behavior.
This module provides intelligent rate limiting that adapts to peer reputation, network conditions, and historical behavior. Unlike static rate limiting, adaptive rate limits increase for trusted peers and decrease for suspicious ones.
§Example
use chie_core::{AdaptiveRateLimiter, AdaptiveRateLimitConfig};
let config = AdaptiveRateLimitConfig {
base_rate: 100,
base_window_secs: 60,
min_rate: 10,
max_rate: 1000,
..Default::default()
};
let mut limiter = AdaptiveRateLimiter::new(config);
// Check if peer can make request
let peer_id = "peer1";
if limiter.check_rate_limit(peer_id, 0.9) {
println!("Request allowed");
} else {
println!("Rate limit exceeded");
}Structs§
- Adaptive
Rate Limit Config - Configuration for adaptive rate limiting.
- Adaptive
Rate Limiter - Adaptive rate limiter with dynamic adjustments.
- Global
Rate Limit Stats - Global rate limit statistics.
- Peer
Rate Limit Stats - Per-peer rate limit statistics.