blockdao

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 34 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")
)
View Source
var ErrIndexOutOfRange = errors.New("index out of range")

ErrIndexOutOfRange indicates the receipt does not exist in the indexer

Functions

func NewBlobStore

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

func WithChecker added in v2.3.0

func WithChecker(ctx context.Context, checker BlockIndexerChecker) context.Context

WithChecker adds BlockIndexerChecker to context

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
}

BlockIndexer defines an interface to accept block to build index

type BlockIndexerChecker

type BlockIndexerChecker interface {
	Height() (uint64, error)
	CheckIndexer(ctx context.Context, indexer BlockIndexer, targetHeight uint64, progressReporter func(uint64)) error
}

BlockIndexerChecker defines a checker of block indexer

func GetChecker added in v2.3.0

func GetChecker(ctx context.Context) BlockIndexerChecker

GetChecker returns the BlockIndexerChecker from context

func MustGetChecker added in v2.3.0

func MustGetChecker(ctx context.Context) BlockIndexerChecker

MustGetChecker returns the BlockIndexerChecker from context, panic if not found

func NewBlockIndexerChecker

func NewBlockIndexerChecker(dao BlockDAO) BlockIndexerChecker

NewBlockIndexerChecker creates a new block indexer checker

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

func NewGrpcBlockDAO added in v2.0.6

func NewGrpcBlockDAO(
	url string,
	insecure bool,
	deserializer *block.Deserializer,
	cacheSize uint64,
) BlockStore

NewGrpcBlockDAO returns a GrpcBlockDAO instance

type Option

type Option func(*blockDAO)

func WithBlobStore

func WithBlobStore(bs BlobStore) Option

func WithReceiptIndexer added in v2.4.0

func WithReceiptIndexer(ri *ReceiptIndexer) Option

WithReceiptIndexer adds receipt indexer to block DAO

type ReceiptIndexer added in v2.4.0

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

ReceiptIndexer defines a struct to store correct receipts for poluted blocks

func NewReceiptIndexer added in v2.4.0

func NewReceiptIndexer(kvstore db.KVStore, endHeight uint64) *ReceiptIndexer

NewReceiptIndexer creates a new receipt indexer

func (*ReceiptIndexer) Height added in v2.4.0

func (ri *ReceiptIndexer) Height() (uint64, error)

Height returns the end height of the receipt indexer

func (*ReceiptIndexer) PutBlock added in v2.4.0

func (ri *ReceiptIndexer) PutBlock(ctx context.Context, blk *block.Block) error

PutBlock puts the receipts of the block into kvstore

func (*ReceiptIndexer) Receipts added in v2.4.0

func (ri *ReceiptIndexer) Receipts(height uint64) ([]*action.Receipt, error)

Receipts returns the receipts of the block at the given height

func (*ReceiptIndexer) Start added in v2.4.0

func (ri *ReceiptIndexer) Start(ctx context.Context) error

Start starts the receipt indexer

func (*ReceiptIndexer) Stop added in v2.4.0

func (ri *ReceiptIndexer) Stop(ctx context.Context) error

Stop stops the receipt indexer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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