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 Record::SIZE
, records are erasure coded, committed to, then roots with proofs are
appended and records become pieces that are returned alongside the corresponding segment 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 new(erasure_coding: ErasureCoding) -> Self
pub fn new(erasure_coding: ErasureCoding) -> Self
Create a new instance
Sourcepub fn with_initial_state(
erasure_coding: ErasureCoding,
segment_header: SegmentHeader,
encoded_block: &[u8],
block_objects: Vec<BlockObject>,
) -> Result<Self, ArchiverInstantiationError>
pub fn with_initial_state( erasure_coding: ErasureCoding, segment_header: SegmentHeader, encoded_block: &[u8], block_objects: Vec<BlockObject>, ) -> 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>,
block_objects: Vec<BlockObject>,
) -> Option<ArchiveBlockOutcome>
pub fn add_block( &mut self, bytes: Vec<u8>, block_objects: Vec<BlockObject>, ) -> Option<ArchiveBlockOutcome>
Adds new block to internal buffer, potentially producing pieces, segment headers, and object mappings.
Returns None
if block is empty or larger than u32::MAX
.
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§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