pub struct RevertibleStore<S> { /* private fields */ }Expand description
A wrapper store that implements rudimentary apply()/reset() support for other stores.
RevertibleStore relies on maintaining a list of processed operations - delete and set.
If it has to revert a failed transaction, it reverts the previous operations as so:
- If reverting an overwriting
setordeleteoperation, it performs asetwith the old value. - If reverting a non-overwriting
set, itdeletes the current value.
Note that this scheme makes it trickier to maintain deterministic Merkle root hashes:
an overwriting set doesnโt reorganize a Merkle tree - but non-overwriting set and delete
operations may reorganize a Merkle tree - which may change the root hash. However, a Merkle
store should have no effect on a failed transaction.
Implementationsยง
Trait Implementationsยง
Sourceยงimpl<S: Clone> Clone for RevertibleStore<S>
impl<S: Clone> Clone for RevertibleStore<S>
Sourceยงfn clone(&self) -> RevertibleStore<S>
fn clone(&self) -> RevertibleStore<S>
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl<S: Debug> Debug for RevertibleStore<S>
impl<S: Debug> Debug for RevertibleStore<S>
Sourceยงimpl<S> Default for RevertibleStore<S>
impl<S> Default for RevertibleStore<S>
Sourceยงimpl<S> ProvableStore for RevertibleStore<S>where
S: ProvableStore,
impl<S> ProvableStore for RevertibleStore<S>where
S: ProvableStore,
Sourceยงimpl<S> Store for RevertibleStore<S>where
S: Store,
impl<S> Store for RevertibleStore<S>where
S: Store,
Sourceยงfn reset(&mut self)
fn reset(&mut self)
Revert all operations in the operation log.
This method doesnโt guarantee that the Merkle tree will be reverted to the correct previous root hash.
It should be avoided. Use InMemoryStore directly which implements a correct rollback procedure.
GH issue: informalsystems/basecoin-rs#129
Sourceยงtype Error = <S as Store>::Error
type Error = <S as Store>::Error
Sourceยงfn set(
&mut self,
path: Path,
value: Vec<u8>,
) -> Result<Option<Vec<u8>>, Self::Error>
fn set( &mut self, path: Path, value: Vec<u8>, ) -> Result<Option<Vec<u8>>, Self::Error>
value for pathSourceยงfn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>
fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>
value for path at specified heightSourceยงfn commit(&mut self) -> Result<Vec<u8>, Self::Error>
fn commit(&mut self) -> Result<Vec<u8>, Self::Error>
Pending block to canonical chain and create new Pending