blockindex

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 29 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 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) Serialize

func (a *ActionIndex) Serialize() []byte

Serialize into 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) Hash

func (b *BlockIndex) Hash() []byte

Hash returns the hash

func (*BlockIndex) NumAction

func (b *BlockIndex) NumAction() uint32

NumAction returns number of actions

func (*BlockIndex) Serialize

func (b *BlockIndex) Serialize() []byte

Serialize into byte stream

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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