blockdao

package
v2.1.3-rc0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRemoteHeightTooLow is the error that remote height is too low
	ErrRemoteHeightTooLow = fmt.Errorf("remote height is too low")
	// ErrAlreadyExist is the error that block already exists
	ErrAlreadyExist = fmt.Errorf("block already exists")
)

Functions

func NewBlobStore

func NewBlobStore(kv db.KVStore, size uint64) *blobStore

Types

type BlobStore

type BlobStore interface {
	Start(context.Context) error
	Stop(context.Context) error
	GetBlob(hash.Hash256) (*types.BlobTxSidecar, string, error)
	GetBlobsByHeight(uint64) ([]*types.BlobTxSidecar, []string, error)
	PutBlock(*block.Block) error
}

BlobStore defines the interface of blob store

type BlockDAO

type BlockDAO interface {
	BlockStore
	GetBlob(hash.Hash256) (*types.BlobTxSidecar, string, error)
	GetBlobsByHeight(uint64) ([]*types.BlobTxSidecar, []string, error)
}

BlockDAO represents the block data access object

func NewBlockDAOWithIndexersAndCache

func NewBlockDAOWithIndexersAndCache(blkStore BlockStore, indexers []BlockIndexer, cacheSize int, opts ...Option) BlockDAO

NewBlockDAOWithIndexersAndCache returns a BlockDAO with indexers which will consume blocks appended, and caches which will speed up reading

type BlockIndexer

type BlockIndexer interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Height() (uint64, error)
	PutBlock(context.Context, *block.Block) error
	DeleteTipBlock(context.Context, *block.Block) error
}

BlockIndexer defines an interface to accept block to build index

type BlockIndexerChecker

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

BlockIndexerChecker defines a checker of block indexer

func NewBlockIndexerChecker

func NewBlockIndexerChecker(dao BlockDAO) *BlockIndexerChecker

NewBlockIndexerChecker creates a new block indexer checker

func (*BlockIndexerChecker) CheckIndexer

func (bic *BlockIndexerChecker) CheckIndexer(ctx context.Context, indexer BlockIndexer, targetHeight uint64, progressReporter func(uint64)) error

CheckIndexer checks a block indexer against block dao

type BlockIndexerWithStart

type BlockIndexerWithStart interface {
	BlockIndexer
	// StartHeight returns the start height of the indexer
	StartHeight() uint64
}

BlockIndexerWithStart defines an interface to accept block to build index from a start height

type BlockStore

type BlockStore interface {
	Start(context.Context) error
	Stop(context.Context) error
	Height() (uint64, error)
	GetBlockHash(uint64) (hash.Hash256, error)
	GetBlockHeight(hash.Hash256) (uint64, error)
	GetBlock(hash.Hash256) (*block.Block, error)
	GetBlockByHeight(uint64) (*block.Block, error)
	GetReceipts(uint64) ([]*action.Receipt, error)
	ContainsTransactionLog() bool
	TransactionLogs(uint64) (*iotextypes.TransactionLogs, error)
	PutBlock(context.Context, *block.Block) error
	Header(hash.Hash256) (*block.Header, error)
	HeaderByHeight(uint64) (*block.Header, error)
	FooterByHeight(uint64) (*block.Footer, error)
}

type GrpcBlockDAO added in v2.0.6

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

func NewGrpcBlockDAO added in v2.0.6

func NewGrpcBlockDAO(
	url string,
	insecure bool,
	deserializer *block.Deserializer,
) *GrpcBlockDAO

func (*GrpcBlockDAO) ContainsTransactionLog added in v2.0.6

func (gbd *GrpcBlockDAO) ContainsTransactionLog() bool

func (*GrpcBlockDAO) FooterByHeight added in v2.0.6

func (gbd *GrpcBlockDAO) FooterByHeight(height uint64) (*block.Footer, error)

func (*GrpcBlockDAO) GetBlock added in v2.0.6

func (gbd *GrpcBlockDAO) GetBlock(h hash.Hash256) (*block.Block, error)

func (*GrpcBlockDAO) GetBlockByHeight added in v2.0.6

func (gbd *GrpcBlockDAO) GetBlockByHeight(height uint64) (*block.Block, error)

func (*GrpcBlockDAO) GetBlockHash added in v2.0.6

func (gbd *GrpcBlockDAO) GetBlockHash(height uint64) (hash.Hash256, error)

func (*GrpcBlockDAO) GetBlockHeight added in v2.0.6

func (gbd *GrpcBlockDAO) GetBlockHeight(h hash.Hash256) (uint64, error)

func (*GrpcBlockDAO) GetReceipts added in v2.0.6

func (gbd *GrpcBlockDAO) GetReceipts(height uint64) ([]*action.Receipt, error)

func (*GrpcBlockDAO) Header added in v2.0.6

func (gbd *GrpcBlockDAO) Header(h hash.Hash256) (*block.Header, error)

func (*GrpcBlockDAO) HeaderByHeight added in v2.0.6

func (gbd *GrpcBlockDAO) HeaderByHeight(height uint64) (*block.Header, error)

func (*GrpcBlockDAO) Height added in v2.0.6

func (gbd *GrpcBlockDAO) Height() (uint64, error)

func (*GrpcBlockDAO) PutBlock added in v2.0.6

func (gbd *GrpcBlockDAO) PutBlock(ctx context.Context, blk *block.Block) error

func (*GrpcBlockDAO) Start added in v2.0.6

func (gbd *GrpcBlockDAO) Start(ctx context.Context) error

func (*GrpcBlockDAO) Stop added in v2.0.6

func (gbd *GrpcBlockDAO) Stop(ctx context.Context) error

func (*GrpcBlockDAO) TransactionLogs added in v2.0.6

func (gbd *GrpcBlockDAO) TransactionLogs(height uint64) (*iotextypes.TransactionLogs, error)

type Option

type Option func(*blockDAO)

func WithBlobStore

func WithBlobStore(bs BlobStore) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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