pub async fn create_archiver_task<Block, CI>(
segment_headers_store: SegmentHeadersStore,
chain_info: CI,
block_importing_notification_receiver: Receiver<BlockImportingNotification>,
archived_segment_notification_sender: Sender<ArchivedSegmentNotification>,
consensus_constants: ConsensusConstants,
create_object_mappings: CreateObjectMappings,
erasure_coding: ErasureCoding,
) -> Result<impl Future<Output = Result<(), ArchiverTaskError>> + Send + 'static, ArchiverTaskError>where
Block: GenericOwnedBlock,
CI: ChainInfo<Block> + 'static,Expand description
Create an archiver task.
Archiver task will listen for importing blocks and archive blocks at K depth, producing pieces
and segment headers (segment headers are then added back to the blockchain in the next block).
NOTE: Archiver is doing blocking operations and must run in a dedicated task.
Archiver is only able to move forward and doesn’t support reorgs. Upon restart, it will check
SegmentHeadersStore and chain history to reconstruct the “current” state it was in before
the last shutdown and continue incrementally archiving blockchain history from there.
Archiving is triggered by block importing notification (block_importing_notification_receiver)
and tries to archive the block at [ConsensusConstants::confirmation_depth_k] depth from the
block being imported. Block importing will then wait for archiver to acknowledge processing,
which is necessary for ensuring that when the next block is imported, the body will contain a
segment header of the newly archived segment.
create_object_mappings controls when object mappings are created for archived blocks. When
these mappings are created.
Once a new segment is archived, a notification (archived_segment_notification_sender) will be
sent and archiver will be paused until all receivers have provided an acknowledgement for it.