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 pending to staged.
  • If it failed, the store reverts the transaction changes by copying staged to pending.

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

source§

fn clone(&self) -> InMemoryStore

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for InMemoryStore

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for InMemoryStore

source§

fn default() -> Self

The store starts out with an empty state. We also initialize the pending location as empty.

source§

impl ProvableStore for InMemoryStore

source§

fn root_hash(&self) -> Vec<u8>

Return a vector commitment
source§

fn get_proof(&self, height: Height, key: &Path) -> Option<CommitmentProof>

Return proof of existence for key
source§

impl Store for InMemoryStore

§

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>

Set value for path
source§

fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>

Get associated value for path at specified height
source§

fn delete(&mut self, path: &Path)

Delete specified path
source§

fn commit(&mut self) -> Result<Vec<u8>, Self::Error>

Commit Pending block to canonical chain and create new Pending
source§

fn apply(&mut self) -> Result<(), Self::Error>

Apply accumulated changes to Pending
source§

fn reset(&mut self)

Reset accumulated changes
source§

fn prune(&mut self, height: RawHeight) -> Result<RawHeight, Self::Error>

Prune historic blocks upto specified height
source§

fn current_height(&self) -> u64

Return the current height of the chain
source§

fn get_keys(&self, key_prefix: &Path) -> Vec<Path>

Return all keys that start with specified prefix

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<A> Async for A
where A: Send + Sync + 'static,