Struct bp_runtime::StorageProofChecker
source · pub struct StorageProofChecker<H>where
H: Hasher,{ /* private fields */ }
Expand description
This struct is used to read storage values from a subset of a Merklized database. The “proof” is a subset of the nodes in the Merkle structure of the database, so that it provides authentication against a known Merkle root as well as the values in the database themselves.
Implementations§
source§impl<H> StorageProofChecker<H>where
H: Hasher,
impl<H> StorageProofChecker<H>where H: Hasher,
sourcepub fn new(root: H::Out, proof: RawStorageProof) -> Result<Self, Error>
pub fn new(root: H::Out, proof: RawStorageProof) -> Result<Self, Error>
Constructs a new storage proof checker.
This returns an error if the given proof is invalid with respect to the given root.
sourcepub fn ensure_no_unused_nodes(self) -> Result<(), Error>
pub fn ensure_no_unused_nodes(self) -> Result<(), Error>
Returns error if the proof has some nodes that are left intact by previous read_value
calls.
sourcepub fn read_value(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>
pub fn read_value(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>
Reads a value from the available subset of storage. If the value cannot be read due to an incomplete or otherwise invalid proof, this function returns an error.
sourcepub fn read_and_decode_value<T: Decode>(
&mut self,
key: &[u8]
) -> Result<Option<T>, Error>
pub fn read_and_decode_value<T: Decode>( &mut self, key: &[u8] ) -> Result<Option<T>, Error>
Reads and decodes a value from the available subset of storage. If the value cannot be read due to an incomplete or otherwise invalid proof, this function returns an error. If value is read, but decoding fails, this function returns an error.
sourcepub fn read_and_decode_mandatory_value<T: Decode>(
&mut self,
key: &[u8]
) -> Result<T, Error>
pub fn read_and_decode_mandatory_value<T: Decode>( &mut self, key: &[u8] ) -> Result<T, Error>
Reads and decodes a value from the available subset of storage. If the value cannot be read
due to an incomplete or otherwise invalid proof, or if the value is None
, this function
returns an error. If value is read, but decoding fails, this function returns an error.
sourcepub fn read_and_decode_opt_value<T: Decode>(
&mut self,
key: &[u8]
) -> Result<Option<T>, Error>
pub fn read_and_decode_opt_value<T: Decode>( &mut self, key: &[u8] ) -> Result<Option<T>, Error>
Reads and decodes a value from the available subset of storage. If the value cannot be read
due to an incomplete or otherwise invalid proof, this function returns Ok(None)
.
If value is read, but decoding fails, this function returns an error.
Auto Trait Implementations§
impl<H> RefUnwindSafe for StorageProofChecker<H>where H: RefUnwindSafe, <H as Hasher>::Out: RefUnwindSafe,
impl<H> Send for StorageProofChecker<H>
impl<H> Sync for StorageProofChecker<H>
impl<H> Unpin for StorageProofChecker<H>where H: Unpin, <H as Hasher>::Out: Unpin,
impl<H> UnwindSafe for StorageProofChecker<H>where H: UnwindSafe, <H as Hasher>::Out: UnwindSafe,
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> CheckedConversion for T
impl<T> CheckedConversion for T
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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.