Module solana_ledger::shred[][src]

Expand description

The shred module defines data structures and methods to pull MTU sized data frames from the network. There are two types of shreds: data and coding. Data shreds contain entry information while coding shreds provide redundancy to protect against dropped network packets (erasures).

+———————————————————————————————+ | Data Shred | +———————————————————————————————+ | common | data | payload | | header | header | | |+—+—+— |+—+—+—|+–––––––––––––––––––––––––––––+––+| || s | s | . || p | f | s || data (ie ledger entries) | r || || i | h | . || a | l | i || | e || || g | r | . || r | a | z || See notes immediately after shred diagrams for an | s || || n | e | || e | g | e || explanation of the “restricted” section in this payload | t || || a | d | || n | s | || | r || || t | | || t | | || | i || || u | t | || | | || | c || || r | y | || o | | || | t || || e | p | || f | | || | e || || | e | || f | | || | d || |+—+—+— |+—+—+—+|–––––––––––––––––––––––––––––+––+| +———————————————————————————————+

+———————————————————————————————+ | Coding Shred | +———————————————————————————————+ | common | coding | payload | | header | header | | |+—+—+— |+—+—+—+––––––––––––––––––––––––––––––––+| || s | s | . || n | n | p || data (encoded data shred data) || || i | h | . || u | u | o || || || g | r | . || m | m | s || || || n | e | || | | i || || || a | d | || d | c | t || || || t | | || | | i || || || u | t | || s | s | o || || || r | y | || h | h | n || || || e | p | || r | r | || || || | e | || e | e | || || || | | || d | d | || || |+—+—+— |+—+—+—+|+–––––––––––––––––––––––––––––––+| +———————————————————————————————+

Notes: a) Coding shreds encode entire data shreds: both of the headers AND the payload. b) Coding shreds require their own headers for identification and etc. c) The erasure algorithm requires data shred and coding shred bytestreams to be equal in length.

So, given a) - c), we must restrict data shred’s payload length such that the entire coding payload can fit into one coding shred / packet.

Structs

CodingShredHeader

The coding shred header has FEC information

DataShredHeader

The data shred header has parent offset and flags

ProcessShredsStats
Shred
ShredCommonHeader

A common header that is present in data and code shred headers

ShredFetchStats
ShredType
Shredder

Enums

ShredError

Constants

CODING_SHRED
DATA_COMPLETE_SHRED
DATA_SHRED

The constants that define if a shred is data or coding

MAX_DATA_SHREDS_PER_FEC_BLOCK
OFFSET_OF_SHRED_INDEX
OFFSET_OF_SHRED_SLOT
OFFSET_OF_SHRED_TYPE
SHRED_PAYLOAD_SIZE
SHRED_TICK_REFERENCE_MASK
SIZE_OF_CODING_SHRED_HEADER
SIZE_OF_CODING_SHRED_HEADERS
SIZE_OF_COMMON_SHRED_HEADER

The following constants are computed by hand, and hardcoded. test_shred_constants ensures that the values are correct. Constants are used over lazy_static for performance reasons.

SIZE_OF_DATA_SHRED_HEADER
SIZE_OF_DATA_SHRED_PAYLOAD
SIZE_OF_NONCE
SIZE_OF_SHRED_INDEX
SIZE_OF_SHRED_SLOT
SIZE_OF_SHRED_TYPE
SIZE_OF_SIGNATURE

Functions

get_shred_slot_index_type
max_entries_per_n_shred
max_ticks_per_n_shreds
verify_test_data_shred

Type Definitions

Nonce
Result