pub struct SqlMerkleStore { /* private fields */ }Expand description
SQL-backed Merkle tree storage (ground truth).
Implementations§
Source§impl SqlMerkleStore
impl SqlMerkleStore
Sourcepub async fn new(connection_string: &str) -> Result<Self, StorageError>
pub async fn new(connection_string: &str) -> Result<Self, StorageError>
Create a new SQL merkle store, initializing schema if needed.
Sourcepub fn from_pool(pool: AnyPool, is_sqlite: bool) -> Self
pub fn from_pool(pool: AnyPool, is_sqlite: bool) -> Self
Create from existing pool (e.g., share with SqlStore).
Sourcepub async fn init_schema(&self) -> Result<(), StorageError>
pub async fn init_schema(&self) -> Result<(), StorageError>
Initialize the schema (creates tables if not exist).
Called automatically by new(), but must be called manually after from_pool().
Sourcepub async fn root_hash(&self) -> Result<Option<[u8; 32]>, StorageError>
pub async fn root_hash(&self) -> Result<Option<[u8; 32]>, StorageError>
Get the root hash (ground truth).
Sourcepub async fn get_hash(
&self,
path: &str,
) -> Result<Option<[u8; 32]>, StorageError>
pub async fn get_hash( &self, path: &str, ) -> Result<Option<[u8; 32]>, StorageError>
Get hash for a specific path.
Sourcepub async fn get_children(
&self,
path: &str,
) -> Result<BTreeMap<String, [u8; 32]>, StorageError>
pub async fn get_children( &self, path: &str, ) -> Result<BTreeMap<String, [u8; 32]>, StorageError>
Get children of an interior node.
Sourcepub async fn get_node(
&self,
path: &str,
) -> Result<Option<MerkleNode>, StorageError>
pub async fn get_node( &self, path: &str, ) -> Result<Option<MerkleNode>, StorageError>
Get a full node (hash + children).
Sourcepub async fn apply_batch(&self, batch: &MerkleBatch) -> Result<(), StorageError>
pub async fn apply_batch(&self, batch: &MerkleBatch) -> Result<(), StorageError>
Apply a batch of merkle updates atomically.
This stores leaf hashes and recomputes affected interior nodes.
Sourcepub async fn diff_children(
&self,
path: &str,
their_children: &BTreeMap<String, [u8; 32]>,
) -> Result<Vec<String>, StorageError>
pub async fn diff_children( &self, path: &str, their_children: &BTreeMap<String, [u8; 32]>, ) -> Result<Vec<String>, StorageError>
Compare with another merkle store and find differing branches.
Returns prefixes where hashes differ (for sync).
Sourcepub async fn get_leaves_under(
&self,
prefix: &str,
) -> Result<Vec<String>, StorageError>
pub async fn get_leaves_under( &self, prefix: &str, ) -> Result<Vec<String>, StorageError>
Get all leaf paths under a prefix (for sync).
Sourcepub async fn count_leaves(&self) -> Result<u64, StorageError>
pub async fn count_leaves(&self) -> Result<u64, StorageError>
Count total objects (leaves) in the tree.
Trait Implementations§
Source§impl Clone for SqlMerkleStore
impl Clone for SqlMerkleStore
Source§fn clone(&self) -> SqlMerkleStore
fn clone(&self) -> SqlMerkleStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SqlMerkleStore
impl !RefUnwindSafe for SqlMerkleStore
impl Send for SqlMerkleStore
impl Sync for SqlMerkleStore
impl Unpin for SqlMerkleStore
impl !UnwindSafe for SqlMerkleStore
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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