Struct basecoin_store::impls::InMemoryStore
source · pub struct InMemoryStore { /* private fields */ }Expand description
An in-memory store backed by an AvlTree.
InMemoryStore has two copies of the current working store - staged and pending.
Each transaction works on the pending copy. When a transaction returns:
- If it succeeded, the store applies the transaction changes by copying
pendingtostaged. - If it failed, the store reverts the transaction changes by copying
stagedtopending.
When a block is committed, the staged copy is copied into the committed store.
Note that this store implementation is not production-friendly. After each transaction,
the entire store is copied from pending to staged, or from staged to pending.
Trait Implementations§
source§impl Clone for InMemoryStore
impl Clone for InMemoryStore
source§fn clone(&self) -> InMemoryStore
fn clone(&self) -> InMemoryStore
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for InMemoryStore
impl Debug for InMemoryStore
source§impl Default for InMemoryStore
impl Default for InMemoryStore
source§impl ProvableStore for InMemoryStore
impl ProvableStore for InMemoryStore
source§impl Store for InMemoryStore
impl Store for InMemoryStore
§type Error = Infallible
type Error = Infallible
Error type - expected to envelope all possible errors in store
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>
Set
value for pathsource§fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>
fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>
Get associated
value for path at specified heightsource§fn commit(&mut self) -> Result<Vec<u8>, Self::Error>
fn commit(&mut self) -> Result<Vec<u8>, Self::Error>
Commit
Pending block to canonical chain and create new Pendingsource§fn prune(&mut self, height: RawHeight) -> Result<RawHeight, Self::Error>
fn prune(&mut self, height: RawHeight) -> Result<RawHeight, Self::Error>
Prune historic blocks upto specified
heightsource§fn current_height(&self) -> u64
fn current_height(&self) -> u64
Return the current height of the chain
Auto Trait Implementations§
impl Freeze for InMemoryStore
impl RefUnwindSafe for InMemoryStore
impl Send for InMemoryStore
impl Sync for InMemoryStore
impl Unpin for InMemoryStore
impl UnwindSafe for InMemoryStore
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