pub struct CommitmentPipeline<S, M = MemoryMmrStore> {
state_store: S,
risk_store: S,
command_mmr: HypercallMmr<M>,
obligation_mmr: HypercallMmr<M>,
intent_mmr: HypercallMmr<M>,
version: Version,
prune_window: u64,
}Expand description
The commitment pipeline.
Generic over the store backend (S) so it works with both
FastMemoryStore (tests) and RocksDbStore (production).
Two separate JMTs:
- State tree: accounts, positions, orders, instruments, oracles, global
- Risk tree: per-account risk metrics (equity, margin, scanning risk)
Plus three MMRs for append-only data (command log, obligations, intents).
Fields§
§state_store: S§risk_store: S§command_mmr: HypercallMmr<M>§obligation_mmr: HypercallMmr<M>§intent_mmr: HypercallMmr<M>§version: Version§prune_window: u64Implementations§
Source§impl CommitmentPipeline<RocksDbStore, RocksDbMmrStore>
impl CommitmentPipeline<RocksDbStore, RocksDbMmrStore>
pub fn checkpoint_inherited_state_root(&self, version: Version) -> Result<bool>
pub fn checkpoint_inherited_risk_root(&self, version: Version) -> Result<bool>
pub fn prune_stores(&self, prune_to: Version) -> Result<(usize, usize)>
pub fn compact_stores(&self) -> Result<()>
Source§impl<S: TreeReader + TreeWriter> CommitmentPipeline<S, MemoryMmrStore>
impl<S: TreeReader + TreeWriter> CommitmentPipeline<S, MemoryMmrStore>
Source§impl<S, M> CommitmentPipeline<S, M>where
S: TreeReader + TreeWriter,
M: MmrMetadataStore + SupportedMmrStore + PrepareMmrStore,
for<'a> &'a M: MMRStoreReadOps<MmrHash> + MMRStoreWriteOps<MmrHash>,
impl<S, M> CommitmentPipeline<S, M>where
S: TreeReader + TreeWriter,
M: MmrMetadataStore + SupportedMmrStore + PrepareMmrStore,
for<'a> &'a M: MMRStoreReadOps<MmrHash> + MMRStoreWriteOps<MmrHash>,
pub fn new_with_mmrs( state_store: S, risk_store: S, command_mmr_store: M, obligation_mmr_store: M, intent_mmr_store: M, prune_window: u64, ) -> Result<Self>
Sourcepub fn with_version(self, version: Version) -> Self
pub fn with_version(self, version: Version) -> Self
Resume from a known version (e.g., after loading from disk).
Sourcepub fn prune_window(&self) -> u64
pub fn prune_window(&self) -> u64
Configured number of recent versions to keep available for proofs.
Sourcepub fn prepare_commit(
&self,
delta: &StateDelta,
) -> Result<PreparedBatchCommitment>
pub fn prepare_commit( &self, delta: &StateDelta, ) -> Result<PreparedBatchCommitment>
Prepare a batch commitment without mutating the backing stores.
Sourcepub fn apply_prepared_commit(
&mut self,
prepared: PreparedBatchCommitment,
) -> Result<BatchCommitment>
pub fn apply_prepared_commit( &mut self, prepared: PreparedBatchCommitment, ) -> Result<BatchCommitment>
Apply a prepared batch commitment after the caller’s durability boundary.
Sourcepub fn commit(&mut self, delta: &StateDelta) -> Result<BatchCommitment>
pub fn commit(&mut self, delta: &StateDelta) -> Result<BatchCommitment>
Commit a batch of state changes and return the new roots.
This is the main entry point for callers that do not need to interpose another durability boundary between root computation and store mutation.
Sourcepub fn append_command(&mut self, command_hash: [u8; 32]) -> Result<()>
pub fn append_command(&mut self, command_hash: [u8; 32]) -> Result<()>
Append a command hash to the command MMR.
Sourcepub fn append_obligation(&mut self, obligation_hash: [u8; 32]) -> Result<()>
pub fn append_obligation(&mut self, obligation_hash: [u8; 32]) -> Result<()>
Append an obligation to the obligation MMR.
Sourcepub fn append_intent(&mut self, intent_hash: [u8; 32]) -> Result<()>
pub fn append_intent(&mut self, intent_hash: [u8; 32]) -> Result<()>
Append a user intent to the intent MMR.
fn latest_root(&self, store: &S, version: Version) -> Result<RootHash>
fn prepare_state_delta( &self, delta: &StateDelta, version: Version, ) -> Result<(RootHash, usize, Option<TreeUpdateBatch>)>
fn prepare_risk_delta( &self, risk_updates: &[RiskUpdate], version: Version, ) -> Result<(RootHash, usize, Option<TreeUpdateBatch>)>
Auto Trait Implementations§
impl<S, M> Freeze for CommitmentPipeline<S, M>
impl<S, M> RefUnwindSafe for CommitmentPipeline<S, M>where
S: RefUnwindSafe,
M: RefUnwindSafe,
impl<S, M> Send for CommitmentPipeline<S, M>
impl<S, M> Sync for CommitmentPipeline<S, M>
impl<S, M> Unpin for CommitmentPipeline<S, M>
impl<S, M> UnsafeUnpin for CommitmentPipeline<S, M>where
S: UnsafeUnpin,
M: UnsafeUnpin,
impl<S, M> UnwindSafe for CommitmentPipeline<S, M>where
S: UnwindSafe,
M: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more