store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when record not found.
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type BlockStore

type BlockStore struct {
	log.Logger

	MinerDb MinerStore
	// contains filtered or unexported fields
}

func NewBlockStore

func NewBlockStore(logger log.Logger) (*BlockStore, error)

func (*BlockStore) Close

func (bs *BlockStore) Close() error

func (*BlockStore) DeleteBlock added in v0.2.0

func (bs *BlockStore) DeleteBlock(height uint64, hash types.Hash)

func (*BlockStore) DeleteData added in v0.2.0

func (bs *BlockStore) DeleteData(hash types.Hash)

func (*BlockStore) DeleteHashByHeight

func (bs *BlockStore) DeleteHashByHeight(height uint64)

func (*BlockStore) DeleteHashByHeightFrom

func (bs *BlockStore) DeleteHashByHeightFrom(height uint64)

func (*BlockStore) DeleteHeader added in v0.2.0

func (bs *BlockStore) DeleteHeader(height uint64, hash types.Hash)

func (*BlockStore) DeleteHeaderHeight

func (bs *BlockStore) DeleteHeaderHeight(hash types.Hash)

DeleteHeaderHeight removes hash->height mapping.

func (*BlockStore) DeleteTd

func (bs *BlockStore) DeleteTd(height uint64, hash types.Hash)

DeleteTd removes all block total difficulty data associated with a hash.

func (*BlockStore) ReadBlock

func (bs *BlockStore) ReadBlock(height uint64, hash types.Hash) *types.Block

func (*BlockStore) ReadData

func (bs *BlockStore) ReadData(hash types.Hash, result interface{}) error

ReadData retrieves the data corresponding to the hash and decode into result.

func (*BlockStore) ReadDataRLP

func (bs *BlockStore) ReadDataRLP(hash types.Hash) rlp.RawValue

ReadDataRLP retrieves the data in RLP encoding.

func (*BlockStore) ReadHashByHeight

func (bs *BlockStore) ReadHashByHeight(height uint64) types.Hash

func (*BlockStore) ReadHeadBlock

func (bs *BlockStore) ReadHeadBlock() *types.Block

func (*BlockStore) ReadHeadBlockHash

func (bs *BlockStore) ReadHeadBlockHash() types.Hash

func (*BlockStore) ReadHeader

func (bs *BlockStore) ReadHeader(height uint64, hash types.Hash) *types.Header

ReadHeader retrieves the block header corresponding to the hash.

func (*BlockStore) ReadHeightByHash

func (bs *BlockStore) ReadHeightByHash(hash types.Hash) *uint64

ReadHeightByHash returns the header height assigned to a hash.

func (*BlockStore) ReadReceipt

func (bs *BlockStore) ReadReceipt(hash types.Hash) (result *types.StoredReceipt)

func (*BlockStore) ReadTd

func (bs *BlockStore) ReadTd(height uint64, hash types.Hash) *big.Int

ReadTd retrieves a block's total difficulty corresponding to the hash.

func (*BlockStore) ReadTx

func (bs *BlockStore) ReadTx(hash types.Hash) (result types.Tx)

func (*BlockStore) WriteBlock

func (bs *BlockStore) WriteBlock(block *types.Block)

func (*BlockStore) WriteData

func (bs *BlockStore) WriteData(hash types.Hash, data interface{})

func (*BlockStore) WriteHashByHeight

func (bs *BlockStore) WriteHashByHeight(height uint64, hash types.Hash, miner types.Address)

GetHashByHeight stores hash by height for the head chain

func (*BlockStore) WriteHeadBlockHash

func (bs *BlockStore) WriteHeadBlockHash(hash types.Hash)

func (*BlockStore) WriteHeader

func (bs *BlockStore) WriteHeader(header *types.Header)

WriteHeader writes the block header corresponding to the hash.

func (*BlockStore) WriteHeightByHash

func (bs *BlockStore) WriteHeightByHash(hash types.Hash, height uint64)

WriteHeightByHash stores the hash->height mapping.

func (*BlockStore) WriteTd

func (bs *BlockStore) WriteTd(height uint64, hash types.Hash, td *big.Int)

WriteTd stores the total difficulty of a block into the database.

type MinerStore added in v0.2.0

type MinerStore interface {
	Close()
	AddMiner(height uint64, miner types.Address) bool
	RemoveMinerByHeight(height uint64) bool
	RemoveMinerFromHeight(height uint64) bool
	CountBlockByMiner(miner types.Address, limit int) int
	QueryBlockByMiner(miner types.Address, limit int, page int) []uint64
}

type MinerStoreNop added in v0.2.0

type MinerStoreNop struct {
}

func (*MinerStoreNop) AddMiner added in v0.2.0

func (*MinerStoreNop) AddMiner(height uint64, miner types.Address) bool

func (*MinerStoreNop) Close added in v0.2.0

func (s *MinerStoreNop) Close()

func (*MinerStoreNop) CountBlockByMiner added in v0.2.0

func (*MinerStoreNop) CountBlockByMiner(miner types.Address, limit int) int

func (*MinerStoreNop) QueryBlockByMiner added in v0.2.0

func (*MinerStoreNop) QueryBlockByMiner(miner types.Address, limit int, page int) []uint64

func (*MinerStoreNop) RemoveMinerByHeight added in v0.2.0

func (*MinerStoreNop) RemoveMinerByHeight(height uint64) bool

func (*MinerStoreNop) RemoveMinerFromHeight added in v0.2.0

func (*MinerStoreNop) RemoveMinerFromHeight(height uint64) bool

Jump to

Keyboard shortcuts

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