Skip to main content

Module ban_list

Module ban_list 

Source
Expand description

Peer ban list for temporary and permanent banning of misbehaving peers.

Provides a tick-based ban management system that supports both temporary bans (which expire after a configurable TTL) and permanent bans (which persist until explicitly removed). The ban list enforces a maximum capacity and tracks statistics about ban/unban operations.

§Example

use ipfrs_network::ban_list::{PeerBanList, BanConfig};

let config = BanConfig::default();
let mut ban_list = PeerBanList::new(config);

// Temporarily ban a peer with default TTL
ban_list.ban_temporary("peer-1", "spamming", None);
assert!(ban_list.is_banned("peer-1"));

// Permanently ban a peer
ban_list.ban_permanent("peer-2", "protocol violation");
assert!(ban_list.is_banned("peer-2"));

// Unban a peer
assert!(ban_list.unban("peer-1"));
assert!(!ban_list.is_banned("peer-1"));

Structs§

BanConfig
Configuration for the peer ban list.
BanEntry
An entry recording a ban against a specific peer.
BanListStats
Aggregate statistics about the ban list.
PeerBanList
Manages a list of banned peers with temporary and permanent ban support.

Enums§

BanKind
The kind of ban applied to a peer.