kv

package
v0.3.3-gamma Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockerIndexer

type BlockerIndexer struct {
	// contains filtered or unexported fields
}

BlockerIndexer implements a block indexer, indexing BeginBlock and EndBlock events with an underlying KV store. Block events are indexed by their height, such that matching search criteria returns the respective block height(s).

func New

func New(store store.KVStore) *BlockerIndexer

func (*BlockerIndexer) Has

func (idx *BlockerIndexer) Has(height int64) (bool, error)

Has returns true if the given height has been indexed. An error is returned upon database query failure.

func (*BlockerIndexer) Index

Index indexes BeginBlock and EndBlock events for a given block by its height. The following is indexed:

primary key: encode(block.height | height) => encode(height) BeginBlock events: encode(eventType.eventAttr|eventValue|height|begin_block) => encode(height) EndBlock events: encode(eventType.eventAttr|eventValue|height|end_block) => encode(height)

func (*BlockerIndexer) Search

func (idx *BlockerIndexer) Search(ctx context.Context, q *query.Query) ([]int64, error)

Search performs a query for block heights that match a given BeginBlock and Endblock event search criteria. The given query can match against zero, one or more block heights. In the case of height queries, i.e. block.height=H, if the height is indexed, that height alone will be returned. An error and nil slice is returned. Otherwise, a non-nil slice and nil error is returned.

Jump to

Keyboard shortcuts

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