cnidarium

Struct Snapshot

Source
pub struct Snapshot(/* private fields */);
Expand description

A snapshot of the underlying storage at a specific state version, suitable for read-only access by multiple threads, e.g., RPC calls.

Snapshots are cheap to create and clone. Internally, they’re implemented as a wrapper around a RocksDB snapshot with a pinned JMT version number for the snapshot.

Implementations§

Source§

impl Snapshot

Source

pub fn version(&self) -> Version

Source

pub async fn get_with_proof( &self, key: Vec<u8>, ) -> Result<(Option<Vec<u8>>, MerkleProof)>

Returns some value corresponding to the key, along with an ICS23 existence proof up to the current JMT root hash. If the key is not present, returns None and a non-existence proof.

Source

pub fn prefix_version(&self, prefix: &str) -> Result<Option<Version>>

Source

pub async fn prefix_root_hash(&self, prefix: &str) -> Result<RootHash>

Returns the root hash of the subtree corresponding to the given prefix. If the prefix is empty, the root hash of the main tree is returned.

§Errors

Returns an error if the supplied prefix does not correspond to a known substore.

Source

pub async fn root_hash(&self) -> Result<RootHash>

Trait Implementations§

Source§

impl Clone for Snapshot

Source§

fn clone(&self) -> Snapshot

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Snapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StateRead for Snapshot

Source§

fn get_raw(&self, key: &str) -> Self::GetRawFut

Fetch a key from the JMT.

Source§

fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut

Fetch a key from nonverifiable storage.

Source§

fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream

Returns a stream of all key-value pairs with the given prefix.

Source§

fn nonverifiable_prefix_raw( &self, prefix: &[u8], ) -> Self::NonconsensusPrefixRawStream

Returns a stream of all key-value pairs with the given prefix, from nonverifiable storage.

Source§

fn nonverifiable_range_raw( &self, prefix: Option<&[u8]>, range: impl RangeBounds<Vec<u8>>, ) -> Result<Self::NonconsensusRangeRawStream>

Returns a stream of all key-value pairs with the given prefix, and range from nonverifiable storage. Important: Only supports range queries over the main store.

Source§

type GetRawFut = SnapshotFuture

Source§

type PrefixRawStream = ReceiverStream<Result<(String, Vec<u8>), Error>>

Source§

type PrefixKeysStream = ReceiverStream<Result<String, Error>>

Source§

type NonconsensusPrefixRawStream = ReceiverStream<Result<(Vec<u8>, Vec<u8>), Error>>

Source§

type NonconsensusRangeRawStream = ReceiverStream<Result<(Vec<u8>, Vec<u8>), Error>>

Source§

fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream

Retrieve all keys (but not values) matching a prefix from the verifiable key-value store.
Source§

fn object_get<T: Any + Send + Sync + Clone>(&self, _key: &str) -> Option<T>

Gets an object from the ephemeral key-object store. Read more
Source§

fn object_type(&self, _key: &str) -> Option<TypeId>

Gets the [TypeId] of the object stored at key in the ephemeral key-object store, if any is present.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more