Skip to main content

Module peer_blacklist

Module peer_blacklist 

Source
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§

BlacklistConfig
Configuration for PeerBlacklist.
BlacklistEntry
A single entry in the blacklist.
BlacklistStats
Aggregate statistics for the blacklist.
PeerBlacklist
Peer blacklist manager.

Enums§

BlacklistReason
Reason why a peer was added to the blacklist.