pub struct Journal<E, C, H, S: State<H::Digest> = Dirty>{ /* private fields */ }Expand description
An append-only data structure that maintains a sequential journal of items alongside a Merkle Mountain Range (MMR). The item at index i in the journal corresponds to the leaf at Location i in the MMR. This structure enables efficient proofs that an item is included in the journal at a specific location.
Implementations§
Source§impl<E, C, H, S> Journal<E, C, H, S>
impl<E, C, H, S> Journal<E, C, H, S>
Sourcepub fn oldest_retained_loc(&self) -> Option<Location>
pub fn oldest_retained_loc(&self) -> Option<Location>
Returns the oldest retained location in the journal.
Sourcepub fn pruning_boundary(&self) -> Location
pub fn pruning_boundary(&self) -> Location
Returns the pruning boundary for the journal.
Source§impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
Sourcepub async fn from_components(
mmr: CleanMmr<E, H::Digest>,
journal: C,
hasher: StandardHasher<H>,
apply_batch_size: u64,
) -> Result<Self, Error>
pub async fn from_components( mmr: CleanMmr<E, H::Digest>, journal: C, hasher: StandardHasher<H>, apply_batch_size: u64, ) -> Result<Self, Error>
Create a new Journal from the given components after aligning the MMR with the journal.
Source§impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
Sourcepub async fn proof(
&self,
start_loc: Location,
max_ops: NonZeroU64,
) -> Result<(Proof<H::Digest>, Vec<C::Item>), Error>
pub async fn proof( &self, start_loc: Location, max_ops: NonZeroU64, ) -> Result<(Proof<H::Digest>, Vec<C::Item>), Error>
Generate a proof of inclusion for items starting at start_loc.
Returns a proof and the items corresponding to the leaves in the range start_loc..end_loc,
where end_loc is the minimum of the current item count and start_loc + max_ops.
§Errors
- Returns Error::Mmr with crate::mmr::Error::LocationOverflow if
start_loc> crate::mmr::MAX_LOCATION. - Returns Error::Mmr with crate::mmr::Error::RangeOutOfBounds if
start_loc>= current item count. - Returns Error::Journal with crate::journal::Error::ItemPruned if
start_lochas been pruned.
Sourcepub async fn historical_proof(
&self,
historical_size: Location,
start_loc: Location,
max_ops: NonZeroU64,
) -> Result<(Proof<H::Digest>, Vec<C::Item>), Error>
pub async fn historical_proof( &self, historical_size: Location, start_loc: Location, max_ops: NonZeroU64, ) -> Result<(Proof<H::Digest>, Vec<C::Item>), Error>
Generate a historical proof with respect to the state of the MMR when it had
historical_size items.
Returns a proof and the items corresponding to the leaves in the range start_loc..end_loc,
where end_loc is the minimum of historical_size and start_loc + max_ops.
§Errors
- Returns Error::Mmr with crate::mmr::Error::LocationOverflow if
historical_sizeorstart_loc> crate::mmr::MAX_LOCATION. - Returns Error::Mmr with crate::mmr::Error::RangeOutOfBounds if
start_loc>=historical_sizeorhistorical_size> number of items in the journal. - Returns Error::Journal with crate::journal::Error::ItemPruned if
start_lochas been pruned.
Sourcepub fn into_dirty(self) -> Journal<E, C, H, Dirty>
pub fn into_dirty(self) -> Journal<E, C, H, Dirty>
Convert this journal into its dirty counterpart for batched updates.
Source§impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
impl<E, C, H> Journal<E, C, H, Clean<H::Digest>>
Source§impl<E, C, H> Journal<E, C, H, Dirty>
impl<E, C, H> Journal<E, C, H, Dirty>
Sourcepub async fn from_components(
mmr: CleanMmr<E, H::Digest>,
journal: C,
hasher: StandardHasher<H>,
apply_batch_size: u64,
) -> Result<Self, Error>
pub async fn from_components( mmr: CleanMmr<E, H::Digest>, journal: C, hasher: StandardHasher<H>, apply_batch_size: u64, ) -> Result<Self, Error>
Create a new dirty journal from aligned components.
Trait Implementations§
Source§impl<E, C, H, S> Contiguous for Journal<E, C, H, S>
impl<E, C, H, S> Contiguous for Journal<E, C, H, S>
Source§type Item = <C as Contiguous>::Item
type Item = <C as Contiguous>::Item
Source§fn size(&self) -> u64
fn size(&self) -> u64
Source§fn oldest_retained_pos(&self) -> Option<u64>
fn oldest_retained_pos(&self) -> Option<u64>
Source§fn pruning_boundary(&self) -> u64
fn pruning_boundary(&self) -> u64
Source§async fn replay(
&self,
start_pos: u64,
buffer: NonZeroUsize,
) -> Result<impl Stream<Item = Result<(u64, Self::Item), JournalError>> + '_, JournalError>
async fn replay( &self, start_pos: u64, buffer: NonZeroUsize, ) -> Result<impl Stream<Item = Result<(u64, Self::Item), JournalError>> + '_, JournalError>
start_pos. Read moreSource§impl<E, C, H> MutableContiguous for Journal<E, C, H, Dirty>
impl<E, C, H> MutableContiguous for Journal<E, C, H, Dirty>
Source§async fn append(&mut self, item: Self::Item) -> Result<u64, JournalError>
async fn append(&mut self, item: Self::Item) -> Result<u64, JournalError>
Source§async fn prune(&mut self, min_position: u64) -> Result<bool, JournalError>
async fn prune(&mut self, min_position: u64) -> Result<bool, JournalError>
min_position. Read moreSource§async fn rewind(&mut self, size: u64) -> Result<(), JournalError>
async fn rewind(&mut self, size: u64) -> Result<(), JournalError>
Source§impl<E, C, H> MutableContiguous for Journal<E, C, H, Clean<H::Digest>>
impl<E, C, H> MutableContiguous for Journal<E, C, H, Clean<H::Digest>>
Source§async fn append(&mut self, item: Self::Item) -> Result<u64, JournalError>
async fn append(&mut self, item: Self::Item) -> Result<u64, JournalError>
Source§async fn prune(&mut self, min_position: u64) -> Result<bool, JournalError>
async fn prune(&mut self, min_position: u64) -> Result<bool, JournalError>
min_position. Read moreSource§async fn rewind(&mut self, size: u64) -> Result<(), JournalError>
async fn rewind(&mut self, size: u64) -> Result<(), JournalError>
Source§impl<E, C, H> PersistableContiguous for Journal<E, C, H, Clean<H::Digest>>
impl<E, C, H> PersistableContiguous for Journal<E, C, H, Clean<H::Digest>>
Source§async fn commit(&mut self) -> Result<(), JournalError>
async fn commit(&mut self) -> Result<(), JournalError>
Source§async fn sync(&mut self) -> Result<(), JournalError>
async fn sync(&mut self) -> Result<(), JournalError>
Auto Trait Implementations§
impl<E, C, H, S> Freeze for Journal<E, C, H, S>
impl<E, C, H, S = Dirty> !RefUnwindSafe for Journal<E, C, H, S>
impl<E, C, H, S> Send for Journal<E, C, H, S>
impl<E, C, H, S> Sync for Journal<E, C, H, S>
impl<E, C, H, S> Unpin for Journal<E, C, H, S>
impl<E, C, H, S = Dirty> !UnwindSafe for Journal<E, C, H, S>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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