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
Supported Solana versions: v1.12.0
Index ¶
- Constants
- Variables
- func GetBincode[T any](db *grocksdb.DB, cf *grocksdb.ColumnFamilyHandle, key []byte) (*T, error)
- func MakeShredKey(slot, index uint64) (key [16]byte)
- func MakeSlotKey(slot uint64) (key [8]byte)
- func MultiGetBincode[T any](db *grocksdb.DB, cf *grocksdb.ColumnFamilyHandle, key ...[]byte) ([]*T, error)
- func ParseBincode[T any](data []byte) (*T, error)
- func ParseSlotKey(key []byte) (uint64, error)
- type Block
- type CompletedRange
- type DB
- func (d *DB) Close()
- func (d *DB) GetBlock(slot uint64) (*Block, error)
- func (d *DB) GetBlockHeight() (uint64, error)
- func (d *DB) GetCodingShred(slot, index uint64) (*grocksdb.Slice, error)
- func (d *DB) GetDataShred(slot, index uint64) (*grocksdb.Slice, error)
- func (d *DB) GetEntriesInDataBlock(slot uint64, startIndex uint32, endIndex uint32) ([]Entry, error)
- func (d *DB) GetSlotEntries(slot uint64, startIndex uint64, allowDeadSlots bool) (entries []Entry, numShreds uint64, isFull bool, err error)
- func (d *DB) GetSlotMeta(slot uint64) (*SlotMeta, error)
- func (d *DB) IsSlotDead(slot uint64) (bool, error)
- func (d *DB) IterCodingShreds(opts *grocksdb.ReadOptions) *grocksdb.Iterator
- func (d *DB) IterDataShreds(opts *grocksdb.ReadOptions) *grocksdb.Iterator
- func (d *DB) IterSlotMetas(opts *grocksdb.ReadOptions) IterBincode[SlotMeta]
- func (d *DB) MaxRoot() (uint64, error)
- func (d *DB) MultiGetSlotMeta(slots ...uint64) ([]*SlotMeta, error)
- func (d *DB) TryCatchUpWithPrimary() error
- type Entry
- type IterBincode
- type SlotMeta
Constants ¶
const ( CfDefault = "default" CfMeta = "meta" CfRoot = "root" CfDeadSlots = "dead_slots" CfBlockHeight = "block_height" CfDataShred = "data_shred" CfCodeShred = "code_shred" )
Column families
Variables ¶
var ErrDeadSlot = errors.New("dead slot")
var ErrInvalidShredData = errors.New("invalid shred data")
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when no row is found.
Functions ¶
func GetBincode ¶
func MakeShredKey ¶
MakeShredKey creates the RocksDB key for CfDataShred or CfCodeShred.
func MakeSlotKey ¶
MakeSlotKey creates the RocksDB key for CfMeta, CfRoot.
func MultiGetBincode ¶
func ParseBincode ¶
func ParseSlotKey ¶
Types ¶
type Block ¶
type Block struct { BlockHash solana.Hash ParentSlot uint64 Transactions []solana.Transaction }
type CompletedRange ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a RocksDB database handle.
func OpenReadOnly ¶
OpenReadOnly attaches to a blockstore in read-only mode.
Attaching to running validators is supported but the DB will only be a point-in-time view at the time of attaching.
func OpenSecondary ¶
OpenSecondary attaches to a blockstore in secondary mode.
Only read operations are allowed. Unlike OpenReadOnly, allows the user to catch up the DB using DB.TryCatchUpWithPrimary.
`secondaryPath` points to a directory where the secondary instance stores its info log.
func (*DB) GetBlockHeight ¶
GetBlockHeight returns the last known root slot.
func (*DB) GetCodingShred ¶
GetCodingShred returns the content of a given coding shred.
func (*DB) GetDataShred ¶
GetDataShred returns the content of a given data shred.
func (*DB) GetEntriesInDataBlock ¶
func (*DB) GetSlotEntries ¶
func (d *DB) GetSlotEntries( slot uint64, startIndex uint64, allowDeadSlots bool, ) (entries []Entry, numShreds uint64, isFull bool, err error)
GetSlotEntries returns the entry vector for the slot starting with `shred_start_index`, the number of shreds that comprise the entry vector, and whether the slot is full (consumed all shreds).
func (*DB) GetSlotMeta ¶
GetSlotMeta returns the shredding metadata of a given slot.
func (*DB) IterCodingShreds ¶
func (d *DB) IterCodingShreds(opts *grocksdb.ReadOptions) *grocksdb.Iterator
IterCodingShreds creates an iterator over CfCodeShred.
Use MakeSlotKey to construct a prefix, or MakeShredKey to seek to a specific shred.
It's the caller's responsibility to close the iterator.
func (*DB) IterDataShreds ¶
func (d *DB) IterDataShreds(opts *grocksdb.ReadOptions) *grocksdb.Iterator
IterDataShreds creates an iterator over CfDataShred.
Use MakeSlotKey to construct a prefix, or MakeShredKey to seek to a specific shred.
It's the caller's responsibility to close the iterator.
func (*DB) IterSlotMetas ¶
func (d *DB) IterSlotMetas(opts *grocksdb.ReadOptions) IterBincode[SlotMeta]
IterSlotMetas creates an iterator over CfMeta.
Use MakeSlotKey to seek to a specific slot.
It's the caller's responsibility to close the iterator.
func (*DB) MultiGetSlotMeta ¶
MultiGetSlotMeta does multiple GetSlotMeta calls.
func (*DB) TryCatchUpWithPrimary ¶
TryCatchUpWithPrimary updates the client's view of the database with the latest information.
Only works with DB opened using OpenSecondary.
type IterBincode ¶
func (IterBincode[T]) Element ¶
func (i IterBincode[T]) Element() (*T, error)
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"` IsConnected bool `yaml:"is_connected"` NumCompletedDataIndexes uint64 `bin:"sizeof=CompletedDataIndexes" yaml:"-"` CompletedDataIndexes []uint32 `yaml:"completed_data_indexes"` }