Expand description
Consensus archiver responsible for archival of blockchain history, it is driven by block import pipeline.
Implements archiving process in Subspace blockchain that converts blockchain history (blocks) into archived history (pieces).
The main entry point here is create_subspace_archiver
that will create a task, which while
driven will perform the archiving itself.
Archiving is triggered by block importing notification (SubspaceLink::block_importing_notification_stream
)
and tries to archive the block at ChainConstants::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, inherents 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
(sc-consensus-subspace-rpc
), but could also be in other ways.
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
[SignedBlock
]s into bytes and back.
Structs§
- Notification with block header hash that needs to be signed and sender for signature.
- Notification with incrementally generated object mappings for a block (and any previous block continuation)
- Persistent storage of segment headers.
Enums§
- Whether to create object mappings.
Functions§
- Create an archiver task.
- Symmetrical to
encode_block()
, used to decode previously encoded blocks - Encode block for archiving purposes.
- Derive genesis segment on demand, returns
Ok(None)
in case genesis block was already pruned