pub struct RedisMerkleStore { /* private fields */ }Expand description
Redis-backed Merkle tree storage.
Uses two key patterns:
{prefix}merkle:hash:{path}-> 32-byte hash (string, hex-encoded){prefix}merkle:children:{path}-> sorted set ofsegment:hashpairs
The optional prefix enables namespacing when sharing Redis with other apps.
Implementations§
Source§impl RedisMerkleStore
impl RedisMerkleStore
Sourcepub fn new(conn: ConnectionManager) -> Self
pub fn new(conn: ConnectionManager) -> Self
Create a new merkle store without a prefix.
Sourcepub fn with_prefix(conn: ConnectionManager, prefix: Option<&str>) -> Self
pub fn with_prefix(conn: ConnectionManager, prefix: Option<&str>) -> Self
Create a new merkle store with an optional prefix.
Sourcepub fn key_prefix(&self) -> &str
pub fn key_prefix(&self) -> &str
Get the prefix used for all merkle keys.
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 the hash for a prefix (interior node or leaf).
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,
prefix: &str,
) -> Result<Option<MerkleNode>, StorageError>
pub async fn get_node( &self, prefix: &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 handles the full bubble-up: updates leaves, then recomputes all affected interior nodes bottom-up.
Trait Implementations§
Source§impl Clone for RedisMerkleStore
impl Clone for RedisMerkleStore
Source§fn clone(&self) -> RedisMerkleStore
fn clone(&self) -> RedisMerkleStore
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 RedisMerkleStore
impl !RefUnwindSafe for RedisMerkleStore
impl Send for RedisMerkleStore
impl Sync for RedisMerkleStore
impl Unpin for RedisMerkleStore
impl !UnwindSafe for RedisMerkleStore
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