pub struct Archiver { /* private fields */ }
Expand description
Block archiver for Subspace blockchain.
It takes new confirmed (at K
depth) blocks and concatenates them into a buffer, buffer is
sliced into segments of [RecordedHistorySegment::SIZE
] size, segments are sliced into source
records of [RawRecord::SIZE
], records are erasure coded, committed to with [Kzg
], then
commitments with witnesses are appended and records become pieces that are returned alongside
corresponding segment header header.
§Panics
Panics when operating on blocks, whose length doesn’t fit into u32 (should never be the case in blockchain context anyway).
Implementations§
source§impl Archiver
impl Archiver
sourcepub fn with_initial_state(
kzg: Kzg,
erasure_coding: ErasureCoding,
segment_header: SegmentHeader,
encoded_block: &[u8],
object_mapping: BlockObjectMapping,
) -> Result<Self, ArchiverInstantiationError>
pub fn with_initial_state( kzg: Kzg, erasure_coding: ErasureCoding, segment_header: SegmentHeader, encoded_block: &[u8], object_mapping: BlockObjectMapping, ) -> Result<Self, ArchiverInstantiationError>
Create a new instance of the archiver with initial state in case of restart.
block
corresponds to last_archived_block
and will be processed according to its state.
sourcepub fn last_archived_block_number(&self) -> Option<BlockNumber>
pub fn last_archived_block_number(&self) -> Option<BlockNumber>
Get last archived block if there was any
sourcepub fn add_block(
&mut self,
bytes: Vec<u8>,
object_mapping: BlockObjectMapping,
incremental: bool,
) -> ArchiveBlockOutcome
pub fn add_block( &mut self, bytes: Vec<u8>, object_mapping: BlockObjectMapping, incremental: bool, ) -> ArchiveBlockOutcome
Adds new block to internal buffer, potentially producing pieces, segment headers, and object mappings.
Incremental archiving can be enabled if amortized block addition cost is preferred over throughput.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Archiver
impl !RefUnwindSafe for Archiver
impl Send for Archiver
impl Sync for Archiver
impl Unpin for Archiver
impl !UnwindSafe for Archiver
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> 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