pub struct Router<O: CompressionOracle> { /* private fields */ }Expand description
In-memory CMR router.
Implementations§
Source§impl<O: CompressionOracle> Router<O>
impl<O: CompressionOracle> Router<O>
Sourcepub fn new(local_address: String, policy: RoutingPolicy, oracle: O) -> Self
pub fn new(local_address: String, policy: RoutingPolicy, oracle: O) -> Self
Creates a router instance.
Registers a pairwise shared key.
Sourcepub fn local_address(&self) -> &str
pub fn local_address(&self) -> &str
Local peer address.
Gets known shared key.
Sourcepub fn policy(&self) -> &RoutingPolicy
pub fn policy(&self) -> &RoutingPolicy
Returns active routing policy.
Sourcepub fn set_policy(&mut self, policy: RoutingPolicy)
pub fn set_policy(&mut self, policy: RoutingPolicy)
Replaces active policy and immediately updates cache limits.
Sourcepub fn peer_snapshots(&self) -> Vec<PeerSnapshot>
pub fn peer_snapshots(&self) -> Vec<PeerSnapshot>
Snapshot of peer metrics.
Sourcepub fn peer_count(&self) -> usize
pub fn peer_count(&self) -> usize
Number of tracked peers.
Sourcepub fn known_keys_count(&self) -> usize
pub fn known_keys_count(&self) -> usize
Number of configured shared keys.
Sourcepub fn pending_key_exchange_count(&self) -> usize
pub fn pending_key_exchange_count(&self) -> usize
Number of pending key exchange initiator states.
Sourcepub fn adjust_reputation(&mut self, peer: &str, delta: f64)
pub fn adjust_reputation(&mut self, peer: &str, delta: f64)
Adjusts peer reputation by delta.
Sourcepub fn remove_peer(&mut self, peer: &str) -> bool
pub fn remove_peer(&mut self, peer: &str) -> bool
Removes a peer from local metrics and key state.
Sourcepub fn record_successful_outbound(&mut self, peer: &str, bytes: usize)
pub fn record_successful_outbound(&mut self, peer: &str, bytes: usize)
Records a successfully delivered outbound message for peer-level accounting.
Sourcepub fn cache_local_client_message(
&mut self,
raw_message: &[u8],
now: CmrTimestamp,
) -> Result<(), ProcessError>
pub fn cache_local_client_message( &mut self, raw_message: &[u8], now: CmrTimestamp, ) -> Result<(), ProcessError>
Inserts a local client-created message into cache without network-ingress checks.
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Current cache summary.
Sourcepub fn cache_entries(&self) -> Vec<CacheEntryView>
pub fn cache_entries(&self) -> Vec<CacheEntryView>
Cache entries for observability.
Sourcepub fn cache_message_distance(
&self,
left_key: &str,
right_key: &str,
) -> Result<Option<f64>, CompressionError>
pub fn cache_message_distance( &self, left_key: &str, right_key: &str, ) -> Result<Option<f64>, CompressionError>
Computes Section 3.2 distance between two cached messages by cache keys.
Sourcepub fn register_pending_rsa_state(
&mut self,
peer: impl Into<String>,
n: BigUint,
d: BigUint,
)
pub fn register_pending_rsa_state( &mut self, peer: impl Into<String>, n: BigUint, d: BigUint, )
Stores pending RSA initiator state for incoming replies.
Sourcepub fn register_pending_dh_state(
&mut self,
peer: impl Into<String>,
p: BigUint,
a_secret: BigUint,
)
pub fn register_pending_dh_state( &mut self, peer: impl Into<String>, p: BigUint, a_secret: BigUint, )
Stores pending DH initiator state for incoming replies.
Sourcepub fn initiate_rsa_key_exchange(
&mut self,
destination: &str,
now: &CmrTimestamp,
) -> Option<ClientMessagePlan>
pub fn initiate_rsa_key_exchange( &mut self, destination: &str, now: &CmrTimestamp, ) -> Option<ClientMessagePlan>
Builds an RSA key-exchange initiation for a destination peer.
Sourcepub fn initiate_dh_key_exchange(
&mut self,
destination: &str,
now: &CmrTimestamp,
) -> Option<ClientMessagePlan>
pub fn initiate_dh_key_exchange( &mut self, destination: &str, now: &CmrTimestamp, ) -> Option<ClientMessagePlan>
Builds a DH key-exchange initiation for a destination peer.
Sourcepub fn initiate_clear_key_exchange(
&mut self,
destination: &str,
clear_key: Vec<u8>,
_now: &CmrTimestamp,
) -> Option<ClientMessagePlan>
pub fn initiate_clear_key_exchange( &mut self, destination: &str, clear_key: Vec<u8>, _now: &CmrTimestamp, ) -> Option<ClientMessagePlan>
Initiates clear key-exchange by sending shared key bytes over a secure channel.
Sourcepub fn process_incoming(
&mut self,
raw_message: &[u8],
transport: TransportKind,
now: CmrTimestamp,
) -> ProcessOutcome
pub fn process_incoming( &mut self, raw_message: &[u8], transport: TransportKind, now: CmrTimestamp, ) -> ProcessOutcome
Processes one inbound message.
Sourcepub fn process_local_client_message(
&mut self,
raw_message: &[u8],
transport: TransportKind,
now: CmrTimestamp,
) -> ProcessOutcome
pub fn process_local_client_message( &mut self, raw_message: &[u8], transport: TransportKind, now: CmrTimestamp, ) -> ProcessOutcome
Processes one local client-originated message.
This path intentionally skips the recipient-address header guard used for network ingress so local compose/injection can originate from the node’s own canonical address.