Module peer_selection

Module peer_selection 

Source
Expand description

Intelligent peer selection module for optimizing content delivery.

This module provides smart peer selection algorithms that combine multiple factors including reputation scores, network quality, load balancing, and geographical proximity to select the best peers for content requests.

§Example

use chie_core::{PeerSelector, SelectionStrategy, PeerCandidate};

let mut selector = PeerSelector::new();

// Add peer candidates with various metrics
selector.add_candidate(PeerCandidate {
    peer_id: "peer1".to_string(),
    reputation_score: 0.95,
    network_health: 0.90,
    current_load: 0.3,
    latency_ms: 50.0,
    bandwidth_mbps: 100.0,
    distance_km: Some(100.0),
    last_seen: std::time::SystemTime::now(),
});

// Select the best peer using weighted scoring
if let Some(best_peer) = selector.select_best() {
    println!("Selected peer: {}", best_peer.peer_id);
}

// Get top N peers for redundancy
let top_peers = selector.select_top_n(3);

Structs§

PeerCandidate
Represents a peer candidate for content delivery.
PeerSelectionStats
Statistics about peer selection.
PeerSelector
Peer selector for intelligent peer ranking and selection.
SelectionWeights
Weights for different factors in peer selection.

Enums§

SelectionStrategy
Peer selection strategy.