blockstore

package
v0.0.0-...-3423c7d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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

View Source
var (
	ErrNotFound         = errors.New("not found")
	ErrDeadSlot         = errors.New("dead slot")
	ErrInvalidShredData = errors.New("invalid shred data")
)

Functions

func MakeShredKey

func MakeShredKey(slot, index uint64) (key [16]byte)

MakeShredKey creates the RocksDB key for CfDataShred or CfCodeShred.

func MakeSlotKey

func MakeSlotKey(slot uint64) (key [8]byte)

MakeSlotKey creates the RocksDB key for CfMeta, CfRoot.

func ParseBincode

func ParseBincode[T any](data []byte) (*T, error)

func ParseShredKey

func ParseShredKey(key []byte) (slot uint64, index uint64, ok bool)

ParseShredKey decodes the RocksDB keys in CfDataShred or CfCodeShred.

func ParseSlotKey

func ParseSlotKey(key []byte) (slot uint64, ok bool)

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

type Entries struct {
	Entries []shred.Entry
	Raw     []byte
	Shreds  []shred.Shred
}

func DataShredsToEntries

func DataShredsToEntries(meta *SlotMeta, shreds []shred.Shred) (entries []Entries, err error)

DataShredsToEntries reassembles shreds to entries containing transactions.

func (*Entries) Slot

func (e *Entries) Slot() uint64

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

func (*SlotMeta) IsFull

func (s *SlotMeta) IsFull() bool

type SubEntries

type SubEntries struct {
	Entries []shred.Entry
}

func (*SubEntries) UnmarshalWithDecoder

func (se *SubEntries) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL