sos_core/commit/
mod.rs

1//! Create and compare commits in an underlying merkle tree.
2mod proof;
3mod tree;
4
5use rs_merkle::{algorithms::Sha256, Hasher};
6use serde::{Deserialize, Serialize};
7
8/// Type for an Sha256 commit tree hash.
9pub type TreeHash = <Sha256 as Hasher>::Hash;
10
11/// Commit hash of zeroes.
12pub const ZERO: TreeHash = [0u8; 32];
13
14pub use proof::{CommitHash, CommitProof, Comparison};
15pub use tree::CommitTree;
16
17/// Commit state combines the last commit hash with
18/// a commit proof.
19#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq)]
20pub struct CommitState(pub CommitHash, pub CommitProof);
21
22/// Commit span represents a section of an event log.
23///
24/// There can be no before commit hash when applying the first
25/// collection of events to an event log. If an empty collection
26/// was passed the after commit hash will be `None`.
27#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq)]
28pub struct CommitSpan {
29    /// Commit hash before changes were applied.
30    pub before: Option<CommitHash>,
31    /// Commit hash after changes were applied.
32    pub after: Option<CommitHash>,
33}