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
impl Snapshot
pub fn version(&self) -> Version
Sourcepub async fn get_with_proof(
&self,
key: Vec<u8>,
) -> Result<(Option<Vec<u8>>, MerkleProof)>
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.
pub fn prefix_version(&self, prefix: &str) -> Result<Option<Version>>
Sourcepub async fn prefix_root_hash(&self, prefix: &str) -> Result<RootHash>
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.
pub async fn root_hash(&self) -> Result<RootHash>
Trait Implementations§
Source§impl StateRead for Snapshot
impl StateRead for Snapshot
Source§fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
Fetch a key from nonverifiable storage.
Source§fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream
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
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>
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.
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
fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream
Auto Trait Implementations§
impl Freeze for Snapshot
impl RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl UnwindSafe for Snapshot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request