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
impl EntropyDriver
Sourcepub fn new(
material: EntropyMaterial,
source: BoxedSnapshotSource,
peers: Arc<RwLock<Vec<Peer>>>,
cadence: Duration,
) -> Self
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.
Sourcepub fn with_peer_port(self, port: u16) -> Self
pub fn with_peer_port(self, port: u16) -> Self
Override the per-peer entropy receiver port.
Sourcepub fn with_buffer_size(self, bytes: usize) -> Self
pub fn with_buffer_size(self, bytes: usize) -> Self
Override the per-chunk plaintext buffer size in bytes.
Sourcepub fn with_header_size(self, bytes: usize) -> Self
pub fn with_header_size(self, bytes: usize) -> Self
Override the snapshot header size in bytes.
Sourcepub fn with_encrypt(self, on: bool) -> Self
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.
Sourcepub async fn run_cycle(&self) -> ReconCycle
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).
Sourcepub async fn run_until_shutdown(self, shutdown: Receiver<bool>)
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§
impl Freeze for EntropyDriver
impl !RefUnwindSafe for EntropyDriver
impl Send for EntropyDriver
impl Sync for EntropyDriver
impl Unpin for EntropyDriver
impl UnsafeUnpin for EntropyDriver
impl !UnwindSafe for EntropyDriver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.