store

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: AGPL-3.0, ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BoltBlockStoreFileName = "blocks.db"

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStore

type BlockStore interface {
	// Add adds the new block to the blockchain.
	Add(b *block.Block) error
	// Get returns the block with given number, or nil if not found.
	Get(blockNumber uint64) (*block.Block, error)
	// Height returns the number of committed blocks in the blockchain.
	Height() (uint64, error)
	// LatestBlock returns the latest committed block.
	LatestBlock() *block.Block
	// SetPendingProposal stores the pending block proposal, nil removed stored proposal.
	SetPendingProposal(proposal *block.PendingBlockProposal) error
	// GetPendingProposal returns the pending block proposal if it exists.
	GetPendingProposal() (*block.PendingBlockProposal, error)
}

BlockStore provides methods to store and query blockchain blocks.

type BoltBlockStore

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

BoltBlockStore is a persistent implementation of BlockStore interface.

func NewBoltBlockStore

func NewBoltBlockStore(dbFile string) (*BoltBlockStore, error)

NewBoltBlockStore creates new on-disk persistent block store using bolt db. If the file does not exist then it will be created, however, parent directories must exist beforehand.

func (*BoltBlockStore) Add

func (bs *BoltBlockStore) Add(b *block.Block) error

func (*BoltBlockStore) Get

func (bs *BoltBlockStore) Get(blockNumber uint64) (*block.Block, error)

func (*BoltBlockStore) GetPendingProposal

func (bs *BoltBlockStore) GetPendingProposal() (*block.PendingBlockProposal, error)

func (*BoltBlockStore) Height

func (bs *BoltBlockStore) Height() (uint64, error)

func (*BoltBlockStore) LatestBlock

func (bs *BoltBlockStore) LatestBlock() *block.Block

func (*BoltBlockStore) SetPendingProposal added in v0.1.3

func (bs *BoltBlockStore) SetPendingProposal(proposal *block.PendingBlockProposal) error

type InMemoryBlockStore

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

InMemoryBlockStore is an in-memory implementation of BlockStore interface.

func NewInMemoryBlockStore

func NewInMemoryBlockStore() *InMemoryBlockStore

func (*InMemoryBlockStore) Add

func (bs *InMemoryBlockStore) Add(b *block.Block) error

func (*InMemoryBlockStore) Get

func (bs *InMemoryBlockStore) Get(blockNumber uint64) (*block.Block, error)

func (*InMemoryBlockStore) GetPendingProposal

func (bs *InMemoryBlockStore) GetPendingProposal() (*block.PendingBlockProposal, error)

func (*InMemoryBlockStore) Height

func (bs *InMemoryBlockStore) Height() (uint64, error)

func (*InMemoryBlockStore) LatestBlock

func (bs *InMemoryBlockStore) LatestBlock() *block.Block

func (*InMemoryBlockStore) SetPendingProposal added in v0.1.3

func (bs *InMemoryBlockStore) SetPendingProposal(proposal *block.PendingBlockProposal) error

Jump to

Keyboard shortcuts

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