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
- type TransactionLogIndexer
- func (ti *TransactionLogIndexer) Put(height uint64, logs *iotextypes.TransactionLogs) error
- func (ti *TransactionLogIndexer) Start(ctx context.Context) error
- func (ti *TransactionLogIndexer) Stop(ctx context.Context) error
- func (ti *TransactionLogIndexer) TransactionLogs(height uint64) (*iotextypes.TransactionLogs, error)
- type TransactionLogIndexerOption
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
func WithTransactionLogIndexer ¶ added in v2.4.3
func WithTransactionLogIndexer(ti *TransactionLogIndexer) Option
WithTransactionLogIndexer adds transaction log 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
type TransactionLogIndexer ¶ added in v2.4.3
type TransactionLogIndexer struct {
// contains filtered or unexported fields
}
TransactionLogIndexer is a read-only, startup-loaded override for block transaction (system) logs. It stores corrected iotextypes.TransactionLogs keyed by block height; only the patched heights are present (the set is sparse, heights need not be contiguous). Transaction logs are not part of any receipt or state root, so overriding them for the patched heights does not affect consensus.
func NewTransactionLogIndexer ¶ added in v2.4.3
func NewTransactionLogIndexer(kvstore db.KVStore, opts ...TransactionLogIndexerOption) *TransactionLogIndexer
NewTransactionLogIndexer creates a new transaction log indexer
func (*TransactionLogIndexer) Put ¶ added in v2.4.3
func (ti *TransactionLogIndexer) Put(height uint64, logs *iotextypes.TransactionLogs) error
Put stores the corrected transaction logs for a block height. Used by the patch generator; must not be called after Start when preloading is enabled.
func (*TransactionLogIndexer) Start ¶ added in v2.4.3
func (ti *TransactionLogIndexer) Start(ctx context.Context) error
Start starts the transaction log indexer
func (*TransactionLogIndexer) Stop ¶ added in v2.4.3
func (ti *TransactionLogIndexer) Stop(ctx context.Context) error
Stop stops the transaction log indexer
func (*TransactionLogIndexer) TransactionLogs ¶ added in v2.4.3
func (ti *TransactionLogIndexer) TransactionLogs(height uint64) (*iotextypes.TransactionLogs, error)
TransactionLogs returns the corrected transaction logs at the given height. It returns db.ErrNotExist / db.ErrBucketNotExist when the height is not patched; callers use that to fall back to the main block store.
type TransactionLogIndexerOption ¶ added in v2.4.3
type TransactionLogIndexerOption func(*TransactionLogIndexer)
TransactionLogIndexerOption configures a TransactionLogIndexer.
func WithPreloadHeights ¶ added in v2.4.3
func WithPreloadHeights() TransactionLogIndexerOption
WithPreloadHeights preloads, at Start, the set of heights that have patched data into memory. Queries for heights not in the set then return without a DB lookup. This is worthwhile for a small, sparse patch where the vast majority of queries are for unpatched heights. Assumes the store is not written after Start (true for the read-only node patch).