Documentation
¶
Index ¶
- Constants
- type BlockStore
- type BoltBlockStore
- func (bs *BoltBlockStore) Add(b *block.Block) error
- func (bs *BoltBlockStore) Get(blockNumber uint64) (*block.Block, error)
- func (bs *BoltBlockStore) GetPendingProposal() (*block.PendingBlockProposal, error)
- func (bs *BoltBlockStore) Height() (uint64, error)
- func (bs *BoltBlockStore) LatestBlock() *block.Block
- func (bs *BoltBlockStore) SetPendingProposal(proposal *block.PendingBlockProposal) error
- type InMemoryBlockStore
- func (bs *InMemoryBlockStore) Add(b *block.Block) error
- func (bs *InMemoryBlockStore) Get(blockNumber uint64) (*block.Block, error)
- func (bs *InMemoryBlockStore) GetPendingProposal() (*block.PendingBlockProposal, error)
- func (bs *InMemoryBlockStore) Height() (uint64, error)
- func (bs *InMemoryBlockStore) LatestBlock() *block.Block
- func (bs *InMemoryBlockStore) SetPendingProposal(proposal *block.PendingBlockProposal) error
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) 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) 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
Click to show internal directories.
Click to hide internal directories.