pub struct UpdateMerkleProof<H: SimpleHasher>(/* private fields */);
Implementations§
Source§impl<H: SimpleHasher> UpdateMerkleProof<H>
impl<H: SimpleHasher> UpdateMerkleProof<H>
pub fn new(merkle_proofs: Vec<SparseMerkleProof<H>>) -> Self
Sourcepub fn verify_update<V: AsRef<[u8]>>(
self,
old_root_hash: RootHash,
new_root_hash: RootHash,
updates: impl AsRef<[(KeyHash, Option<V>)]>,
) -> Result<()>
pub fn verify_update<V: AsRef<[u8]>>( self, old_root_hash: RootHash, new_root_hash: RootHash, updates: impl AsRef<[(KeyHash, Option<V>)]>, ) -> Result<()>
Verifies an update of the [JellyfishMerkleTree
], proving the transition from an old_root_hash
to a new_root_hash
(RootHash
)
Multiple cases to handle:
- Insert a tuple
new_element_key
,new_element_value
- Update a tuple
new_element_key
,new_element_value
- Delete the
new_element_key
This function does the following high level operations:
- Verify the Merkle path provided against the
old_root_hash
- Use the provided Merkle path and the tuple (
new_element_key
,new_element_value
) to compute the new Merkle path. - Compare the new Merkle path against the new_root_hash
If these steps are verified then the [
JellyfishMerkleTree
] has been soundly updated
This function consumes the Merkle proof to avoid uneccessary copying.
Trait Implementations§
Source§impl<H> BorshDeserialize for UpdateMerkleProof<H>where
H: BorshDeserialize + SimpleHasher,
impl<H> BorshDeserialize for UpdateMerkleProof<H>where
H: BorshDeserialize + SimpleHasher,
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl<H> BorshSerialize for UpdateMerkleProof<H>where
H: BorshSerialize + SimpleHasher,
impl<H> BorshSerialize for UpdateMerkleProof<H>where
H: BorshSerialize + SimpleHasher,
Source§impl<H: Debug + SimpleHasher> Debug for UpdateMerkleProof<H>
impl<H: Debug + SimpleHasher> Debug for UpdateMerkleProof<H>
Source§impl<'de, H> Deserialize<'de> for UpdateMerkleProof<H>where
H: Deserialize<'de> + SimpleHasher,
impl<'de, H> Deserialize<'de> for UpdateMerkleProof<H>where
H: Deserialize<'de> + SimpleHasher,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<H> Serialize for UpdateMerkleProof<H>where
H: Serialize + SimpleHasher,
impl<H> Serialize for UpdateMerkleProof<H>where
H: Serialize + SimpleHasher,
Auto Trait Implementations§
impl<H> Freeze for UpdateMerkleProof<H>
impl<H> RefUnwindSafe for UpdateMerkleProof<H>where
H: RefUnwindSafe,
impl<H> Send for UpdateMerkleProof<H>where
H: Send,
impl<H> Sync for UpdateMerkleProof<H>where
H: Sync,
impl<H> Unpin for UpdateMerkleProof<H>where
H: Unpin,
impl<H> UnwindSafe for UpdateMerkleProof<H>where
H: 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
Mutably borrows from an owned value. Read more
§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>
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