Expand description
Anomaly detection module for identifying suspicious behavior and fraud.
This module provides statistical anomaly detection to identify unusual patterns in bandwidth proofs, peer behavior, and network activity. It uses multiple detection strategies including z-score analysis, rate-based detection, and pattern matching.
§Example
use chie_core::{AnomalyDetector, DetectionConfig, BehaviorSample};
let config = DetectionConfig::default();
let mut detector = AnomalyDetector::new(config);
// Record normal behavior
for i in 0..100 {
detector.record_sample("peer1", BehaviorSample {
value: 100.0 + (i as f64 % 10.0),
timestamp: std::time::SystemTime::now(),
metric_type: "bandwidth".to_string(),
});
}
// Check for anomaly
let sample = BehaviorSample {
value: 500.0, // Unusual spike
timestamp: std::time::SystemTime::now(),
metric_type: "bandwidth".to_string(),
};
if detector.is_anomalous("peer1", &sample) {
println!("Anomaly detected!");
}Structs§
- Anomaly
- Detected anomaly information.
- Anomaly
Detector - Anomaly detector for identifying suspicious behavior.
- Anomaly
Stats - Anomaly detection statistics.
- Behavior
Sample - Sample of peer behavior for analysis.
- Detection
Config - Configuration for anomaly detection.
Enums§
- Anomaly
Type - Anomaly type classification.