Documentation ¶
Index ¶
- Constants
- Variables
- type BloomFilterIndexer
- type Config
- type IndexBuilder
- type Indexer
- type SGDIndex
- type SGDRegistry
- type SyncIndexers
- func (ig *SyncIndexers) DeleteTipBlock(ctx context.Context, blk *block.Block) error
- func (ig *SyncIndexers) Height() (uint64, error)
- func (ig *SyncIndexers) PutBlock(ctx context.Context, blk *block.Block) error
- func (ig *SyncIndexers) Start(ctx context.Context) error
- func (ig *SyncIndexers) StartHeight() uint64
- func (ig *SyncIndexers) Stop(ctx context.Context) error
Constants ¶
const ( // BlockBloomFilterNamespace indicated the kvstore namespace to store block BloomFilters BlockBloomFilterNamespace = "BlockBloomFilters" // RangeBloomFilterNamespace indicates the kvstore namespace to store range BloomFilters RangeBloomFilterNamespace = "RangeBloomFilters" // CurrentHeightKey indicates the key of current bf indexer height in underlying DB CurrentHeightKey = "CurrentHeight" )
Variables ¶
var DefaultConfig = Config{
RangeBloomFilterNumElements: 100000,
RangeBloomFilterSize: 1200000,
RangeBloomFilterNumHash: 8,
}
DefaultConfig is the default config of indexer
var ( // ErrActionIndexNA indicates action index is not supported ErrActionIndexNA = errors.New("action index not supported") )
var ( // TotalBloomFilterNamespace indicates the kvstore namespace to store total ranges TotalBloomFilterNamespace = []byte("TotalBloomFilters") )
Functions ¶
This section is empty.
Types ¶
type BloomFilterIndexer ¶ added in v1.1.3
type BloomFilterIndexer interface { blockdao.BlockIndexer // RangeBloomFilterNumElements returns the number of elements that each rangeBloomfilter indexes RangeBloomFilterNumElements() uint64 // BlockFilterByHeight returns the block-level bloomfilter which includes not only topic but also address of logs info by given block height BlockFilterByHeight(uint64) (bloom.BloomFilter, error) // FilterBlocksInRange returns the block numbers by given logFilter in range from start to end FilterBlocksInRange(*filter.LogFilter, uint64, uint64, uint64) ([]uint64, error) }
BloomFilterIndexer is the interface for bloomfilter indexer
func NewBloomfilterIndexer ¶ added in v1.1.3
func NewBloomfilterIndexer(kv db.KVStore, cfg Config) (BloomFilterIndexer, error)
NewBloomfilterIndexer creates a new bloomfilterindexer struct by given kvstore and rangebloomfilter size
type Config ¶ added in v1.8.4
type Config struct { // RangeBloomFilterNumElements is the number of elements each rangeBloomfilter will store in bloomfilterIndexer RangeBloomFilterNumElements uint64 `yaml:"rangeBloomFilterNumElements"` // RangeBloomFilterSize is the size (in bits) of rangeBloomfilter RangeBloomFilterSize uint64 `yaml:"rangeBloomFilterSize"` // RangeBloomFilterNumHash is the number of hash functions of rangeBloomfilter RangeBloomFilterNumHash uint64 `yaml:"rangeBloomFilterNumHash"` }
Config is the config for indexer
type IndexBuilder ¶
type IndexBuilder struct {
// contains filtered or unexported fields
}
IndexBuilder defines the index builder
func NewIndexBuilder ¶
func NewIndexBuilder(chainID uint32, g genesis.Genesis, dao blockdao.BlockDAO, indexer Indexer) (*IndexBuilder, error)
NewIndexBuilder instantiates an index builder
func (*IndexBuilder) Indexer ¶
func (ib *IndexBuilder) Indexer() Indexer
Indexer returns the indexer
func (*IndexBuilder) ReceiveBlock ¶
func (ib *IndexBuilder) ReceiveBlock(blk *block.Block) error
ReceiveBlock handles the block and create the indices for the actions and receipts in it
type Indexer ¶
type Indexer interface { Start(context.Context) error Stop(context.Context) error PutBlock(context.Context, *block.Block) error PutBlocks(context.Context, []*block.Block) error DeleteTipBlock(context.Context, *block.Block) error Height() (uint64, error) GetBlockHash(height uint64) (hash.Hash256, error) GetBlockHeight(hash hash.Hash256) (uint64, error) GetBlockIndex(uint64) (*blockIndex, error) GetActionIndex([]byte) (*actionIndex, error) GetTotalActions() (uint64, error) GetActionHashFromIndex(uint64, uint64) ([][]byte, error) GetActionCountByAddress(hash.Hash160) (uint64, error) GetActionsByAddress(hash.Hash160, uint64, uint64) ([][]byte, error) }
Indexer is the interface for block indexer
type SGDRegistry ¶ added in v1.11.0
type SGDRegistry interface { blockdao.BlockIndexerWithStart // CheckContract returns the contract's eligibility for SGD and percentage CheckContract(context.Context, string, uint64) (address.Address, uint64, bool, error) // FetchContracts returns all contracts that are eligible for SGD FetchContracts(context.Context, uint64) ([]*SGDIndex, error) }
SGDRegistry is the interface for Sharing of Gas-fee with DApps
func NewSGDRegistry ¶ added in v1.11.0
func NewSGDRegistry(contract string, startHeight uint64, kv db.KVStore) SGDRegistry
NewSGDRegistry creates a new SGDIndexer
type SyncIndexers ¶ added in v1.11.1
type SyncIndexers struct {
// contains filtered or unexported fields
}
SyncIndexers is a special index that includes multiple indexes, which stay in sync when blocks are added.
func NewSyncIndexers ¶ added in v1.11.1
func NewSyncIndexers(indexers ...blockdao.BlockIndexer) *SyncIndexers
NewSyncIndexers creates a new SyncIndexers each indexer will PutBlock one by one in the order of the indexers
func (*SyncIndexers) DeleteTipBlock ¶ added in v1.11.1
DeleteTipBlock deletes the tip block from the indexers in the group
func (*SyncIndexers) Height ¶ added in v1.11.1
func (ig *SyncIndexers) Height() (uint64, error)
Height returns the minimum height of the indexers in the group
func (*SyncIndexers) PutBlock ¶ added in v1.11.1
PutBlock puts a block into the indexers in the group
func (*SyncIndexers) Start ¶ added in v1.11.1
func (ig *SyncIndexers) Start(ctx context.Context) error
Start starts the indexer group
func (*SyncIndexers) StartHeight ¶ added in v1.11.1
func (ig *SyncIndexers) StartHeight() uint64
StartHeight returns the minimum start height of the indexers in the group