store

package
v0.0.0-...-4ef5390 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockPartSizeBytes is the size of one block part.
	BlockPartSizeBytes = 65536 // 64kB
)

Variables

This section is empty.

Functions

func SaveBlockStoreStateBatch

func SaveBlockStoreStateBatch(bsj *BlockStoreState, batch dbm.Batch)

SaveBlockStoreStateBatch persists the blockStore state to the database. It uses the DB batch passed as parameter

Types

type BlockMeta

type BlockMeta struct {
	PartSetSize int
}

TODO: make proto, low priority

type BlockStore

type BlockStore struct {
	// contains filtered or unexported fields
}

BlockStore is a simple low level store for non-contiguous blocks.

// NOTE: BlockStore methods will panic if they encounter errors // deserializing loaded data, indicating probable corruption on disk.

func NewBlockStore

func NewBlockStore(db dbm.DB) *BlockStore

NewBlockStore returns a new BlockStore with the given DB, initialized to the last height that was committed to the DB.

func (*BlockStore) Base

func (bs *BlockStore) Base() int64

Base returns the first known contiguous block height, or 0 for empty block stores.

func (*BlockStore) Close

func (bs *BlockStore) Close() error

func (*BlockStore) Height

func (bs *BlockStore) Height() int64

Height returns the last known contiguous block height, or 0 for empty block stores.

func (*BlockStore) IsEmpty

func (bs *BlockStore) IsEmpty() bool

Empty of contiguous block (may contain non-contiguous blocks)

func (*BlockStore) LoadBlock

func (bs *BlockStore) LoadBlock(height int64) []byte

LoadBlock returns the block with the given height. If no block is found for that height, it returns nil.

func (*BlockStore) LoadBlockMeta

func (bs *BlockStore) LoadBlockMeta(height int64) *BlockMeta

LoadBlockMeta returns the BlockMeta for the given height. If no block is found for the given height, it returns nil.

func (*BlockStore) LoadBlockPart

func (bs *BlockStore) LoadBlockPart(height int64, partIndex int) []byte

LoadBlockPart returns the Part at the given index from the block at the given height. If no part is found for the given height and index, it returns nil.

func (*BlockStore) PruneBlocks

func (bs *BlockStore) PruneBlocks(height int64) (uint64, error)

PruneBlocks removes block up to (but not including) a height. It returns number of blocks pruned.

func (*BlockStore) SaveBlock

func (bs *BlockStore) SaveBlock(height int64, block []byte)

SaveBlock persists the given block, blockParts, and seenCommit to the underlying db. blockParts: Must be parts of the block seenCommit: The +2/3 precommits that were seen which committed at height.

If all the nodes restart after committing a block,
we need this to reload the precommits to catch-up nodes to the
most recent height.  Otherwise they'd stall at H-1.

func (*BlockStore) SetInitialState

func (bs *BlockStore) SetInitialState(height int64)

type BlockStoreState

type BlockStoreState struct {
	Base   int64 `json:"base"`
	Height int64 `json:"height"`
}

TODO: make proto, low priority

func LoadBlockStoreState

func LoadBlockStoreState(db dbm.DB) BlockStoreState

LoadBlockStoreState returns the BlockStoreState as loaded from disk. If no BlockStoreState was previously persisted, it returns the zero value.

type PartSet

type PartSet struct {
	// contains filtered or unexported fields
}

func NewPartSetFromData

func NewPartSetFromData(data []byte, partSize int) *PartSet

func (*PartSet) GetPart

func (p *PartSet) GetPart(i int) []byte

func (*PartSet) Total

func (p *PartSet) Total() int

Jump to

Keyboard shortcuts

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