pub struct Immutable<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> { /* private fields */ }Expand description
An authenticated database that only supports adding new keyed values (no updates or deletions), where values can have varying sizes.
Implementations§
Source§impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> Immutable<E, K, V, H, T>
impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> Immutable<E, K, V, H, T>
Sourcepub async fn size(&self) -> Location
pub async fn size(&self) -> Location
Return the Location of the next operation appended to this db.
Sourcepub async fn bounds(&self) -> Range<Location>
pub async fn bounds(&self) -> Range<Location>
Return [start, end) where start and end - 1 are the Locations of the oldest and newest
retained operations respectively.
Sourcepub async fn get(&self, key: &K) -> Result<Option<V>, Error>
pub async fn get(&self, key: &K) -> Result<Option<V>, Error>
Get the value of key in the db, or None if it has no value or its corresponding operation
has been pruned.
Sourcepub async fn get_metadata(&self) -> Result<Option<V>, Error>
pub async fn get_metadata(&self) -> Result<Option<V>, Error>
Get the metadata associated with the last commit.
Sourcepub async fn historical_proof(
&self,
op_count: Location,
start_loc: Location,
max_ops: NonZeroU64,
) -> Result<(Proof<H::Digest>, Vec<Operation<K, V>>), Error>
pub async fn historical_proof( &self, op_count: Location, start_loc: Location, max_ops: NonZeroU64, ) -> Result<(Proof<H::Digest>, Vec<Operation<K, V>>), Error>
Analogous to proof but with respect to the state of the database when it had op_count
operations.
§Errors
Returns crate::mmr::Error::LocationOverflow if op_count or start_loc >
crate::mmr::MAX_LOCATION.
Returns crate::mmr::Error::RangeOutOfBounds if op_count > number of operations, or
if start_loc >= op_count.
Returns Error::OperationPruned if start_loc has been pruned.
Sourcepub async fn prune(&mut self, loc: Location) -> Result<(), Error>
pub async fn prune(&mut self, loc: Location) -> Result<(), Error>
Prune operations prior to prune_loc. This does not affect the db’s root, but it will
affect retrieval of any keys that were set prior to prune_loc.
§Errors
- Returns Error::PruneBeyondMinRequired if
prune_loc> last commit location. - Returns crate::mmr::Error::LocationOverflow if
prune_loc> crate::mmr::MAX_LOCATION.
Sourcepub async fn proof(
&self,
start_index: Location,
max_ops: NonZeroU64,
) -> Result<(Proof<H::Digest>, Vec<Operation<K, V>>), Error>
pub async fn proof( &self, start_index: Location, max_ops: NonZeroU64, ) -> Result<(Proof<H::Digest>, Vec<Operation<K, V>>), Error>
Generate and return:
- a proof of all operations applied to the db in the range starting at (and including)
location
start_loc, and ending at the first of either:- the last operation performed, or
- the operation
max_opsfrom the start.
- the operations corresponding to the leaves in this range.
Sourcepub async fn init(
context: E,
cfg: Config<T, <Operation<K, V> as Read>::Cfg>,
) -> Result<Self, Error>
pub async fn init( context: E, cfg: Config<T, <Operation<K, V> as Read>::Cfg>, ) -> Result<Self, Error>
Returns an Immutable qmdb initialized from cfg. Any uncommitted log operations will be
discarded and the state of the db will be as of the last committed operation.
Sourcepub async fn sync(&mut self) -> Result<(), Error>
pub async fn sync(&mut self) -> Result<(), Error>
Sync all database state to disk. While this isn’t necessary to ensure durability of committed operations, periodic invocation may reduce memory usage and the time required to recover the database on restart.
Sourcepub fn new_batch(
&self,
) -> UnmerkleizedBatch<'_, E, K, V, H, T, Mmr<E, H::Digest>>
pub fn new_batch( &self, ) -> UnmerkleizedBatch<'_, E, K, V, H, T, Mmr<E, H::Digest>>
Create a new speculative batch of operations with this database as its parent.
Sourcepub async fn apply_batch(
&mut self,
batch: Changeset<K, H::Digest, V>,
) -> Result<Range<Location>, Error>
pub async fn apply_batch( &mut self, batch: Changeset<K, H::Digest, V>, ) -> Result<Range<Location>, Error>
Apply a changeset to the database.
A changeset is only valid if the database has not been modified since the
batch that produced it was created. Multiple batches can be forked from the
same parent for speculative execution, but only one may be applied. Applying
a stale changeset returns Error::StaleChangeset.
Returns the range of locations written.
Trait Implementations§
Source§impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> Gettable for Immutable<E, K, V, H, T>
impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> Gettable for Immutable<E, K, V, H, T>
Source§impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> LogStore for Immutable<E, K, V, H, T>
impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> LogStore for Immutable<E, K, V, H, T>
type Value = V
Source§async fn bounds(&self) -> Range<Location>
async fn bounds(&self) -> Range<Location>
start and end - 1 are the Locations of the oldest and newest
retained operations respectively.Source§impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> MerkleizedStore for Immutable<E, K, V, H, T>
impl<E: RStorage + Clock + Metrics, K: Array, V: VariableValue, H: CHasher, T: Translator> MerkleizedStore for Immutable<E, K, V, H, T>
Auto Trait Implementations§
impl<E, K, V, H, T> !Freeze for Immutable<E, K, V, H, T>
impl<E, K, V, H, T> !RefUnwindSafe for Immutable<E, K, V, H, T>
impl<E, K, V, H, T> Send for Immutable<E, K, V, H, T>
impl<E, K, V, H, T> Sync for Immutable<E, K, V, H, T>
impl<E, K, V, H, T> Unpin for Immutable<E, K, V, H, T>
impl<E, K, V, H, T> UnsafeUnpin for Immutable<E, K, V, H, T>where
T: UnsafeUnpin,
H: UnsafeUnpin,
E: UnsafeUnpin,
<H as Hasher>::Digest: UnsafeUnpin,
<V as Read>::Cfg: UnsafeUnpin,
<E as Storage>::Blob: UnsafeUnpin,
impl<E, K, V, H, T> !UnwindSafe for Immutable<E, K, V, H, T>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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