blockindex

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var DefaultConfig = Config{
	RangeBloomFilterNumElements: 100000,
	RangeBloomFilterSize:        1200000,
	RangeBloomFilterNumHash:     8,
}

DefaultConfig is the default config of indexer

View Source
var (

	// ErrActionIndexNA indicates action index is not supported
	ErrActionIndexNA = errors.New("action index not supported")
)
View Source
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

func (*IndexBuilder) Start

func (ib *IndexBuilder) Start(ctx context.Context) error

Start starts the index builder

func (*IndexBuilder) Stop

func (ib *IndexBuilder) Stop(ctx context.Context) error

Stop stops the index builder

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

func NewIndexer

func NewIndexer(kv db.KVStore, genesisHash hash.Hash256) (Indexer, error)

NewIndexer creates a new indexer

type SGDIndex added in v1.11.0

type SGDIndex struct {
	Contract address.Address
	Receiver address.Address
	Approved bool
}

SGDIndex is the struct for SGDIndex

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

func (ig *SyncIndexers) DeleteTipBlock(ctx context.Context, blk *block.Block) error

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

func (ig *SyncIndexers) PutBlock(ctx context.Context, blk *block.Block) error

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

func (*SyncIndexers) Stop added in v1.11.1

func (ig *SyncIndexers) Stop(ctx context.Context) error

Stop stops the indexer group

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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