Skip to main content

EntropyDriver

Struct EntropyDriver 

Source
pub struct EntropyDriver { /* private fields */ }
Expand description

Periodic reconciliation driver.

Constructed by the embedding binary once the entropy key / IV material has been loaded; spawned as a tokio task with EntropyDriver::run_until_shutdown.

§Examples

use std::sync::Arc;
use std::time::Duration;
use parking_lot::RwLock;
use dynomite::entropy::driver::EntropyDriver;
use dynomite::entropy::send::StaticSnapshot;
use dynomite::entropy::util::{EntropyIv, EntropyKey, EntropyMaterial};

let mat = EntropyMaterial::new(
    EntropyKey::from_bytes([0x10; 16]),
    EntropyIv::from_bytes([0x42; 16]),
);
let source: dynomite::entropy::BoxedSnapshotSource =
    Arc::new(StaticSnapshot::new(Vec::new()));
let peers = Arc::new(RwLock::new(Vec::new()));
let driver = EntropyDriver::new(mat, source, peers, Duration::from_secs(300));
assert_eq!(driver.cadence(), Duration::from_secs(300));

Implementations§

Source§

impl EntropyDriver

Source

pub fn new( material: EntropyMaterial, source: BoxedSnapshotSource, peers: Arc<RwLock<Vec<Peer>>>, cadence: Duration, ) -> Self

Build a driver with the default entropy port and chunk sizes.

Source

pub fn with_peer_port(self, port: u16) -> Self

Override the per-peer entropy receiver port.

Source

pub fn with_buffer_size(self, bytes: usize) -> Self

Override the per-chunk plaintext buffer size in bytes.

Source

pub fn with_header_size(self, bytes: usize) -> Self

Override the snapshot header size in bytes.

Source

pub fn with_encrypt(self, on: bool) -> Self

Disable AES-128-CBC encryption of per-chunk payloads. Intended for tests; production deployments leave the encryption flag at its default of true.

Source

pub fn cadence(&self) -> Duration

Reconciliation cadence.

Source

pub fn peer_port(&self) -> u16

Per-peer entropy receiver port the driver dials.

Source

pub async fn run_cycle(&self) -> ReconCycle

Run a single reconciliation cycle: visit every non-local peer in the pool, attempt one snapshot push each, and return the aggregated ReconCycle.

Per-peer failures are logged at WARN and recorded as peers_attempted (without bumping peers_exchanged).

Source

pub async fn run_until_shutdown(self, shutdown: Receiver<bool>)

Drive the periodic loop until shutdown is set.

The first cycle runs immediately, mirroring how the reference engine’s entropy thread eagerly synchronises on startup; subsequent cycles fire on cadence. A shutdown observed mid-cycle is honoured at the next per-peer boundary so the in-flight peer interaction completes (the driver does not abort the AES handshake mid-frame).

Auto Trait Implementations§

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,