store

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStore

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

BlockStore is a simple low level store for blocks.

There are three types of information stored:

  • BlockMeta: Meta information about each block
  • Block part: Parts of each block, aggregated w/ PartSet
  • Commit: The commit part of each block, for gossiping precommit votes

Currently the precommit signatures are duplicated in the Block parts as well as the Commit. In the future this may change, perhaps by moving the Commit data outside the Block. (TODO)

// 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) DB

func (bs *BlockStore) DB() dbm.DB

DB returns the database the store reads and writes.

func (*BlockStore) FlushPoint

func (bs *BlockStore) FlushPoint() (FlushPoint, bool)

FlushPoint returns the last block-sync flush point's record, and false if there is none.

func (*BlockStore) Height

func (bs *BlockStore) Height() int64

Height returns the last known contiguous block height.

func (*BlockStore) LoadBlock

func (bs *BlockStore) LoadBlock(height int64) *types.Block

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

func (*BlockStore) LoadBlockCommit

func (bs *BlockStore) LoadBlockCommit(height int64) *types.Commit

LoadBlockCommit returns the Commit for the given height. This commit consists of the +2/3 and other Precommit-votes for block at `height`, and it comes from the block.LastCommit for `height+1`. If no commit is found for the given height, it returns nil.

func (*BlockStore) LoadBlockMeta

func (bs *BlockStore) LoadBlockMeta(height int64) *types.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, index int) *types.Part

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) LoadSeenCommit

func (bs *BlockStore) LoadSeenCommit(height int64) *types.Commit

LoadSeenCommit returns the locally seen Commit for the given height. This is useful when we've seen a commit, but there has not yet been a new block at `height + 1` that includes this commit in its block.LastCommit.

func (*BlockStore) LowerHeight

func (bs *BlockStore) LowerHeight(height int64)

LowerHeight lowers the store's height to height, on disk and in memory. The records above it stay in place, unread, until SaveBlock saves those heights again over them. The handshake calls it after a crash in a block-sync flush point (see FlushPoint).

func (*BlockStore) SaveBlock

func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)

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.

type BlockStoreStateJSON

type BlockStoreStateJSON struct {
	Height int64 `json:"height"`
}

BlockStoreStateJSON is the block store state JSON structure.

func LoadBlockStoreStateJSON

func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON

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

func (BlockStoreStateJSON) Save

func (bsj BlockStoreStateJSON) Save(db dbm.DB)

Save persists the blockStore state to the database as JSON.

type FlushPoint

type FlushPoint struct {
	From int64 `json:"from"`
	To   int64 `json:"to"`
}

FlushPoint is the record a block-sync flush point writes with the block store's batch, its first write: the window it writes, from the last flush point's height to its own. A crash before its second write, the state's, leaves the block store ahead of the state by that window; the record lets the handshake tell that shape from any other, such as a partial restore, which it refuses as before.

func (FlushPoint) Save

func (fp FlushPoint) Save(db dbm.DB)

Save writes the record to db, without a sync: it rides in the batch of the block store's held writes.

Jump to

Keyboard shortcuts

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