Module geo_selection

Module geo_selection 

Source
Expand description

Geographic-aware peer selection for optimal content delivery.

This module provides geographic intelligence for peer selection, including:

  • Haversine distance calculation between geographic coordinates
  • Region-based peer grouping
  • Geographic diversity scoring
  • Proximity-based peer ranking

§Example

use chie_core::geo_selection::{GeoLocation, GeoPeer, GeoSelector, GeoConfig};

let config = GeoConfig::default();
let mut selector = GeoSelector::new(config);

// Add peers with geographic locations
selector.add_peer(GeoPeer {
    peer_id: "peer1".to_string(),
    location: GeoLocation::new(37.7749, -122.4194), // San Francisco
    region: "us-west".to_string(),
    latency_ms: 50.0,
    bandwidth_mbps: 100.0,
});

selector.add_peer(GeoPeer {
    peer_id: "peer2".to_string(),
    location: GeoLocation::new(40.7128, -74.0060), // New York
    region: "us-east".to_string(),
    latency_ms: 120.0,
    bandwidth_mbps: 100.0,
});

// Find nearest peer to a location
let target = GeoLocation::new(37.3382, -121.8863); // San Jose
let nearest = selector.find_nearest(&target, 5);

Structs§

GeoConfig
Configuration for geographic peer selection.
GeoLocation
Geographic location with latitude and longitude.
GeoPeer
A peer with geographic location information.
GeoSelector
Geographic peer selector.
GeoStats
Geographic distribution statistics.

Functions§

haversine_distance
Calculate the Haversine distance between two geographic locations.
midpoint
Calculate the midpoint between two locations.