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).