pub struct SegmentHeadersStore<AS> { /* private fields */ }
Expand description
Persistent storage of segment headers.
It maintains all known segment headers. During sync from DSN it is possible that this data structure contains segment headers that from the point of view of the tip of the current chain are “in the future”. This is expected and must be accounted for in the archiver and other places.
Segment headers are stored in batches (which is more efficient to store and retrieve). Each next batch contains distinct segment headers with monotonically increasing segment indices. During instantiation all previously stored batches will be read and in-memory representation of the whole contents will be created such that queries to this data structure are quick and not involving any disk I/O.
Implementations§
source§impl<AS> SegmentHeadersStore<AS>where
AS: AuxStore,
impl<AS> SegmentHeadersStore<AS>where
AS: AuxStore,
sourcepub fn new(
aux_store: Arc<AS>,
confirmation_depth_k: BlockNumber,
) -> Result<Self>
pub fn new( aux_store: Arc<AS>, confirmation_depth_k: BlockNumber, ) -> Result<Self>
Create new instance
sourcepub fn last_segment_header(&self) -> Option<SegmentHeader>
pub fn last_segment_header(&self) -> Option<SegmentHeader>
Returns last observed segment header
sourcepub fn max_segment_index(&self) -> Option<SegmentIndex>
pub fn max_segment_index(&self) -> Option<SegmentIndex>
Returns last observed segment index
sourcepub fn add_segment_headers(
&self,
segment_headers: &[SegmentHeader],
) -> Result<()>
pub fn add_segment_headers( &self, segment_headers: &[SegmentHeader], ) -> Result<()>
Add segment headers.
Multiple can be inserted for efficiency purposes.
sourcepub fn get_segment_header(
&self,
segment_index: SegmentIndex,
) -> Option<SegmentHeader>
pub fn get_segment_header( &self, segment_index: SegmentIndex, ) -> Option<SegmentHeader>
Get a single segment header
sourcepub fn segment_headers_for_block(
&self,
block_number: BlockNumber,
) -> Vec<SegmentHeader>
pub fn segment_headers_for_block( &self, block_number: BlockNumber, ) -> Vec<SegmentHeader>
Get segment headers that are expected to be included at specified block number.
Trait Implementations§
source§impl<AS> Clone for SegmentHeadersStore<AS>
impl<AS> Clone for SegmentHeadersStore<AS>
Auto Trait Implementations§
impl<AS> Freeze for SegmentHeadersStore<AS>
impl<AS> !RefUnwindSafe for SegmentHeadersStore<AS>
impl<AS> Send for SegmentHeadersStore<AS>
impl<AS> Sync for SegmentHeadersStore<AS>
impl<AS> Unpin for SegmentHeadersStore<AS>
impl<AS> !UnwindSafe for SegmentHeadersStore<AS>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.