Module archiving

Module archiving 

Source
Expand description

Consensus archiver responsible for archival of blockchain history, it is driven by the block import pipeline.

Implements archiving process in that converts blockchain history (blocks) into archived history (segments and pieces).

The main entry point here is create_archiver_task that will create a task, which while driven will perform the archiving itself.

Archiving is triggered by block importing notification and tries to archive the block at ConsensusConstants::confirmation_depth_k depth from the block being imported. Block import will then wait for archiver to acknowledge processing, which is necessary for ensuring that when the next block is imported, it will contain segment header of newly archived block (must happen exactly in the next block).

Archiving itself will also wait for acknowledgement by various subscribers before proceeding, which includes farmer subscription, in case of reference implementation via RPC.

SegmentHeadersStore is maintained as a data structure containing all known (including future in case of syncing) segment headers. This data structure contents is then made available to other parts of the protocol that need to know what correct archival history of the blockchain looks like. For example, it is used during node sync and farmer plotting in order to verify pieces of archival history received from other network participants.

recreate_genesis_segment is a bit of a hack and is useful for deriving of the genesis segment that is special case since we don’t have enough data in the blockchain history itself during genesis in order to do the archiving.

encode_block and decode_block are symmetric encoding/decoding functions turning Blocks into bytes and back.

Structs§

ArchivedSegmentNotification
Notification with a new archived segment that was just archived
ObjectMappingNotification
Notification with incrementally generated object mappings for a block (and any previous block continuation)

Enums§

ArchiverTaskError
Archiver task error
CreateObjectMappings
Whether to create object mappings.

Functions§

create_archiver_task
Create an archiver task.
decode_block
Symmetrical to encode_block(), used to decode previously encoded blocks
encode_block
Encode block for archiving purposes
recreate_genesis_segment
Derive the genesis segment on demand, returns Ok(None) in case the genesis block was already pruned