Documentation ¶
Overview ¶
Package blockstore is a read-only client for the Solana blockstore database.
For the reference implementation in Rust, see here: https://docs.rs/solana-ledger/latest/solana_ledger/blockstore/struct.Blockstore.html
This package requires Cgo to access RocksDB (via grocksdb).
Compatibility ¶
We aim to support all Solana Rust versions since mainnet genesis. Test fixtures are added for each major revision.
Index ¶
- Constants
- Variables
- func MakeShredKey(slot, index uint64) (key [16]byte)
- func MakeSlotKey(slot uint64) (key [8]byte)
- func ParseBincode[T any](data []byte) (*T, error)
- func ParseShredKey(key []byte) (slot uint64, index uint64, ok bool)
- func ParseSlotKey(key []byte) (slot uint64, ok bool)
- type BlockWalkI
- type Entries
- type SlotMeta
- type SubEntries
Constants ¶
const ( // CfDefault is the default column family, which is required by RocksDB. CfDefault = "default" // CfMeta contains slot metadata (SlotMeta) // // Similar to a block header, but not cryptographically authenticated. CfMeta = "meta" // CfErasureMeta contains erasure coding metadata CfErasureMeta = "erasure_meta" // CfRoot is a single cell specifying the current root slot number CfRoot = "root" // CfDataShred contains ledger data. // // One or more shreds make up a single entry. // The shred => entry surjection is indicated by SlotMeta.EntryEndIndexes CfDataShred = "data_shred" // CfCodeShred contains FEC shreds used to fix data shreds CfCodeShred = "code_shred" // CfDeadSlots contains slots that have been marked as dead CfDeadSlots = "dead_slots" CfBlockHeight = "block_height" CfBankHash = "bank_hashes" CfTxStatus = "transaction_status" CfTxStatusIndex = "transaction_status_index" CfAddressSig = "address_signatures" CfTxMemos = "transaction_memos" CfRewards = "rewards" CfBlockTime = "blocktime" CfPerfSamples = "perf_samples" CfProgramCosts = "program_costs" CfOptimisticSlots = "optimistic_slots" )
Column families
Variables ¶
Functions ¶
func MakeShredKey ¶
MakeShredKey creates the RocksDB key for CfDataShred or CfCodeShred.
func MakeSlotKey ¶
MakeSlotKey creates the RocksDB key for CfMeta, CfRoot.
func ParseBincode ¶
func ParseShredKey ¶
ParseShredKey decodes the RocksDB keys in CfDataShred or CfCodeShred.
func ParseSlotKey ¶
ParseSlotKey decodes the RocksDB keys in CfMeta, CfRoot.
Types ¶
type BlockWalkI ¶
type BlockWalkI interface { Seek(slot uint64) (ok bool) SlotsAvailable() (total uint64) Next() (meta *SlotMeta, ok bool) Close() // Entries returns the block contents of a slot. // // The outer returned slice contains batches of entries. // Each batch is made up from multiple shreds and shreds and batches are aligned. // The SlotMeta.EntryEndIndexes mark the indexes of the last shreds in each batch, // thus `len(SlotMeta.EntryEndIndexes)` equals `len(batches)`. // // The inner slices are the entries in each shred batch, usually sized one. Entries(meta *SlotMeta) (batches [][]shred.Entry, err error) }
BlockWalkI abstracts iterators over block data.
The main (and only) implementation in this package is BlockWalk.
type Entries ¶
func DataShredsToEntries ¶
DataShredsToEntries reassembles shreds to entries containing transactions.
type SlotMeta ¶
type SlotMeta struct { Slot uint64 `yaml:"-"` Consumed uint64 `yaml:"consumed"` Received uint64 `yaml:"received"` FirstShredTimestamp uint64 `yaml:"first_shred_timestamp"` LastIndex uint64 `yaml:"last_index"` // optional, None being math.MaxUint64 ParentSlot uint64 `yaml:"parent_slot"` // optional, None being math.MaxUint64 NumNextSlots uint64 `bin:"sizeof=NextSlots" yaml:"-"` NextSlots []uint64 `yaml:"next_slots,flow"` IsConnected bool `yaml:"is_connected"` // shred indexes that mark the end of an entry (used for shreds => entry mapping) NumEntryEndIndexes uint64 `bin:"sizeof=EntryEndIndexes" yaml:"-"` EntryEndIndexes []uint32 `yaml:"completed_data_indexes,flow"` }
SlotMeta is data stored in CfMeta
type SubEntries ¶
func (*SubEntries) UnmarshalWithDecoder ¶
func (se *SubEntries) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)