Skip to main content

Router

Struct Router 

Source
pub struct Router<O: CompressionOracle> { /* private fields */ }
Expand description

In-memory CMR router.

Implementations§

Source§

impl<O: CompressionOracle> Router<O>

Source

pub fn new(local_address: String, policy: RoutingPolicy, oracle: O) -> Self

Creates a router instance.

Source

pub fn set_shared_key(&mut self, peer: impl Into<String>, key: Vec<u8>)

Registers a pairwise shared key.

Source

pub fn local_address(&self) -> &str

Local peer address.

Source

pub fn shared_key(&self, peer: &str) -> Option<&[u8]>

Gets known shared key.

Source

pub fn policy(&self) -> &RoutingPolicy

Returns active routing policy.

Source

pub fn set_policy(&mut self, policy: RoutingPolicy)

Replaces active policy and immediately updates cache limits.

Source

pub fn peer_snapshots(&self) -> Vec<PeerSnapshot>

Snapshot of peer metrics.

Source

pub fn peer_count(&self) -> usize

Number of tracked peers.

Source

pub fn known_keys_count(&self) -> usize

Number of configured shared keys.

Source

pub fn pending_key_exchange_count(&self) -> usize

Number of pending key exchange initiator states.

Source

pub fn adjust_reputation(&mut self, peer: &str, delta: f64)

Adjusts peer reputation by delta.

Source

pub fn remove_peer(&mut self, peer: &str) -> bool

Removes a peer from local metrics and key state.

Source

pub fn record_successful_outbound(&mut self, peer: &str, bytes: usize)

Records a successfully delivered outbound message for peer-level accounting.

Source

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.

Source

pub fn cache_stats(&self) -> CacheStats

Current cache summary.

Source

pub fn cache_entries(&self) -> Vec<CacheEntryView>

Cache entries for observability.

Source

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.

Source

pub fn register_pending_rsa_state( &mut self, peer: impl Into<String>, n: BigUint, d: BigUint, )

Stores pending RSA initiator state for incoming replies.

Source

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.

Source

pub fn initiate_rsa_key_exchange( &mut self, destination: &str, now: &CmrTimestamp, ) -> Option<ClientMessagePlan>

Builds an RSA key-exchange initiation for a destination peer.

Source

pub fn initiate_dh_key_exchange( &mut self, destination: &str, now: &CmrTimestamp, ) -> Option<ClientMessagePlan>

Builds a DH key-exchange initiation for a destination peer.

Source

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.

Source

pub fn process_incoming( &mut self, raw_message: &[u8], transport: TransportKind, now: CmrTimestamp, ) -> ProcessOutcome

Processes one inbound message.

Source

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.

Auto Trait Implementations§

§

impl<O> Freeze for Router<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for Router<O>
where O: RefUnwindSafe,

§

impl<O> Send for Router<O>

§

impl<O> Sync for Router<O>

§

impl<O> Unpin for Router<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for Router<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for Router<O>
where O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V