Documentation ¶
Index ¶
- Constants
- Variables
- type ActionIndex
- type BlockIndex
- type BloomFilterIndexer
- type Config
- type IndexBuilder
- type Indexer
- 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 ActionIndex ¶
type ActionIndex struct {
// contains filtered or unexported fields
}
ActionIndex change private to public for mock Indexer
func (*ActionIndex) BlockHeight ¶
func (a *ActionIndex) BlockHeight() uint64
Height returns the block height of action
func (*ActionIndex) Deserialize ¶
func (a *ActionIndex) Deserialize(buf []byte) error
Deserialize from byte stream
func (*ActionIndex) TxNumber ¶ added in v2.0.6
func (a *ActionIndex) TxNumber() uint32
TxNumber returns the transaction number of action
type BlockIndex ¶
type BlockIndex struct {
// contains filtered or unexported fields
}
BlockIndex change private to public for mock Indexer
func (*BlockIndex) Deserialize ¶
func (b *BlockIndex) Deserialize(buf []byte) error
Deserialize from byte stream
func (*BlockIndex) NumAction ¶
func (b *BlockIndex) NumAction() uint32
NumAction returns number of actions
func (*BlockIndex) TsfAmount ¶
func (b *BlockIndex) TsfAmount() *big.Int
TsfAmount returns transfer amount
type BloomFilterIndexer ¶
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 ¶
func NewBloomfilterIndexer(kv db.KVStore, cfg Config) (BloomFilterIndexer, error)
NewBloomfilterIndexer creates a new bloomfilterindexer struct by given kvstore and rangebloomfilter size
type Config ¶
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.BlockStore, 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 SyncIndexers ¶
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 ¶
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 ¶
DeleteTipBlock deletes the tip block from the indexers in the group
func (*SyncIndexers) Height ¶
func (ig *SyncIndexers) Height() (uint64, error)
Height returns the minimum height of the indexers in the group
func (*SyncIndexers) Start ¶
func (ig *SyncIndexers) Start(ctx context.Context) error
Start starts the indexer group
func (*SyncIndexers) StartHeight ¶
func (ig *SyncIndexers) StartHeight() uint64
StartHeight returns the minimum start height of the indexers in the group