store

package
v0.0.0-...-f47aca1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 7 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 是一个简单的区块存储。

有三种类型的信息会被储存:

  • BlockMeta: 每个区块的元数据
  • Block part: 每个块的部分,通过PartSet聚合
  • Commit: 每个区块的提交部分,用于gossip传播precommit投票

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 使用给定的DB返回一个BlockStore,初始化并读取已经存在的区块。

func (*BlockStore) Base

func (bs *BlockStore) Base() int64

Base 返回第一个已知的连续块高度,如果是空的存储,返回0

func (*BlockStore) Height

func (bs *BlockStore) Height() int64

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

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

func (bs *BlockStore) LoadBlockByHash(hash []byte) *types.Block

LoadBlockByHash returns the block with the given hash. If no block is found for that hash, it returns nil. Panics if it fails to parse height associated with the given hash.

func (*BlockStore) LoadBlockCommit

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

LoadBlockCommit 返回指定高度的commit. 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 返回给定高度的本地可见提交. 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) 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(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.

func (*BlockStore) Size

func (bs *BlockStore) Size() int64

Size returns the number of blocks in the block store.

type BlockStoreStateJSON

type BlockStoreStateJSON struct {
	Base   int64 `json:"base"`
	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.

Jump to

Keyboard shortcuts

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