Expand description
Peer blacklist with expiry, reason tracking, and reputation-based auto-blacklisting.
Provides a wall-clock-time-aware blacklist for peers, supporting:
- Manual blocking with optional expiry
- Strike-based automatic blacklisting with configurable thresholds
- Permanent escalation after repeated offences
- Fine-grained reason classification
- Aggregate statistics
§Example
use ipfrs_network::peer_blacklist::{PeerBlacklist, BlacklistConfig, BlacklistReason};
let config = BlacklistConfig::default();
let mut bl = PeerBlacklist::new(config);
// Manually block a peer for 60 seconds (in milliseconds)
let now = 1_000_000u64;
bl.block("peer-1", BlacklistReason::ManualBlock, "test block", Some(now + 60_000));
assert!(bl.is_blocked_at("peer-1", now));
// Record strikes to trigger auto-block
let count = bl.record_strike("peer-2", now);
assert!(count >= 1);Structs§
- Blacklist
Config - Configuration for
PeerBlacklist. - Blacklist
Entry - A single entry in the blacklist.
- Blacklist
Stats - Aggregate statistics for the blacklist.
- Peer
Blacklist - Peer blacklist manager.
Enums§
- Blacklist
Reason - Reason why a peer was added to the blacklist.