use serde::{Serialize, Deserialize};
use std::time::Instant;
use epoekie::AID;
pub const VERSION: &str = "1.2.1-Alpha";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IqaSeal {
pub aid_hash: [u8; 32],
pub signature: Vec<u8>,
pub timestamp: u64,
pub is_radiant: bool,
}
impl IqaSeal {
pub fn ghost() -> Self {
Self {
aid_hash: [0u8; 32],
signature: vec![],
timestamp: 0,
is_radiant: false,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NeuralPulse {
pub origin: AID,
pub payload: Vec<u8>,
pub seal: IqaSeal,
pub tx_instant: u64,
}
impl NeuralPulse {
pub fn new(origin: AID, payload: Vec<u8>, seal: IqaSeal) -> Self {
Self {
origin,
payload,
seal,
tx_instant: Instant::now().elapsed().as_nanos() as u64,
}
}
}
pub trait NerveCenter {
fn shunt_pulse(&self, pulse: NeuralPulse) -> Result<(), NerveError>;
fn sync_latency(&self) -> u64;
}
#[derive(Debug, thiserror::Error)]
pub enum NerveError {
#[error("Neural Transport Congestion Detected")]
Congestion,
#[error("Semantic Routing Failure")]
RoutingFailure,
#[error("Pulse Integrity Violation [RFC-003 RPKI]")]
IntegrityViolation,
}