Struct oasis_core_runtime::storage::mkvs::OverlayTree

source ·
pub struct OverlayTree<T: FallibleMKVS> { /* private fields */ }
Expand description

A key-value tree overlay that holds all updates in memory and only commits them if requested. This can be used to create snapshots that can be discarded.

While updates (inserts, removes) are stored in the overlay, reads are not cached in the overlay as the inner tree has its own cache and double caching makes less sense.

Implementations§

source§

impl<T: FallibleMKVS> OverlayTree<T>

source

pub fn new(inner: T) -> Self

Create a new overlay tree.

source

pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>

Get an existing key.

source

pub fn get_proof(&self, key: &[u8]) -> Result<Option<Proof>>

source

pub fn insert(&mut self, key: &[u8], value: &[u8]) -> Result<Option<Vec<u8>>>

Insert a key/value pair into the tree.

source

pub fn remove(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>

Remove entry with given key, returning the value at the key if the key was previously in the database.

source

pub fn iter(&self) -> OverlayTreeIterator<'_, T>

Return an iterator over the tree.

source

pub fn commit(&mut self) -> Result<WriteLog>

Commit any modifications to the underlying tree.

source

pub fn commit_both( &mut self, namespace: Namespace, version: u64, ) -> Result<(WriteLog, Hash)>

Commit any modifications to the underlying tree and then immediately commit the underlying tree, returning the new root hash.

Trait Implementations§

source§

impl<T: FallibleMKVS> MKVS for OverlayTree<T>

source§

fn get(&self, key: &[u8]) -> Option<Vec<u8>>

Fetch entry with given key.
source§

fn get_proof(&self, key: &[u8]) -> Option<Proof>

Fetch proof for entry with given key.
source§

fn cache_contains_key(&self, key: &[u8]) -> bool

Check if the local MKVS cache contains the given key. Read more
source§

fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>

Update entry with given key. Read more
source§

fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>

Remove entry with given key, returning the value at the key if the key was previously in the database.
source§

fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16)

Populate the in-memory tree with nodes for keys starting with given prefixes.
source§

fn iter(&self) -> Box<dyn Iterator + '_>

Returns an iterator over the tree.
source§

fn commit( &mut self, namespace: Namespace, version: u64, ) -> Result<(WriteLog, Hash)>

Commit all database changes to the underlying store.

Auto Trait Implementations§

§

impl<T> Freeze for OverlayTree<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for OverlayTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for OverlayTree<T>
where T: Send,

§

impl<T> Sync for OverlayTree<T>
where T: Sync,

§

impl<T> Unpin for OverlayTree<T>
where T: Unpin,

§

impl<T> UnwindSafe for OverlayTree<T>
where T: UnwindSafe,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,