Documentation
¶
Index ¶
- Variables
- func NewBlobStore(kv db.KVStore, size uint64) *blobStore
- func WithChecker(ctx context.Context, checker BlockIndexerChecker) context.Context
- type BlobStore
- type BlockDAO
- type BlockIndexer
- type BlockIndexerChecker
- type BlockStore
- type Option
- type ReceiptIndexer
- func (ri *ReceiptIndexer) Height() (uint64, error)
- func (ri *ReceiptIndexer) PutBlock(ctx context.Context, blk *block.Block) error
- func (ri *ReceiptIndexer) Receipts(height uint64) ([]*action.Receipt, error)
- func (ri *ReceiptIndexer) Start(ctx context.Context) error
- func (ri *ReceiptIndexer) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
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") )
var ErrIndexOutOfRange = errors.New("index out of range")
ErrIndexOutOfRange indicates the receipt does not exist in the indexer
Functions ¶
func NewBlobStore ¶
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)
}
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 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
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