Skip to main content

Module segment

Module segment 

Source
Expand description

Segment archiving.

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

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

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

All segment headers of the archived segments are available to other parts of the protocol that need to know what the correct archival history of the blockchain looks like through [ChainInfo]. For example, it is used during node sync and farmer plotting to verify pieces of archival history received from other network participants. Future segment header might also be already known in the case of syncing from DSN.

recreate_genesis_segment is a bit of a hack and is useful for deriving of the genesis beacon chain segment that is a special case since we don’t have enough data in the blockchain history itself during genesis 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

Enums§

SegmentArchiverTaskError
Segment archiver task error

Functions§

create_segment_archiver_task
Create a segment 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