Skip to main content

SyncStore

Trait SyncStore 

Source
pub trait SyncStore {
    // Required methods
    fn account_id(&self) -> [u8; 32];
    fn snapshot(&self) -> Result<Vec<([u8; 32], Vec<u8>)>>;
    fn ingest(&mut self, signed_bytes: &[u8]) -> Result<Ingested>;
}
Expand description

The store side of a session: what a peer offers and where received entries land. Implemented over the op log for production and over an in-memory map for tests.

Required Methods§

Source

fn account_id(&self) -> [u8; 32]

The account this session is scoped to. A peer whose hello names a different account is a misdirected connection and the session aborts.

Source

fn snapshot(&self) -> Result<Vec<([u8; 32], Vec<u8>)>>

Every held account-log entry as (dedup_key, signed_bytes), read ONCE at session start. The key is the SIGNED-envelope hash (sha256(signed_bytes)), NOT the entry_hash — two envelopes can share an entry_hash but differ in signature, and the wire must treat them as distinct or a peer holding one would suppress the other. Snapshotting up front keeps what we send independent of what we concurrently ingest, so the two session halves never contend.

Source

fn ingest(&mut self, signed_bytes: &[u8]) -> Result<Ingested>

Ingest one received entry’s signed_bytes. Must be idempotent (re-ingesting a held entry is a no-op) and must re-verify — the bytes came off the wire from an untrusted peer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§