Struct cnidarium::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. TODO(erwan): For now this method only supports range queries over the main store.

§

type GetRawFut = SnapshotFuture

§

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

§

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

§

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

§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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