txindex

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorEmptyHash = errors.New("transaction hash cannot be empty")

ErrorEmptyHash indicates empty hash

Functions

func DeduplicateBatch

func DeduplicateBatch(ops []*abci.TxResult, txIdxr TxIndexer) ([]*abci.TxResult, error)

DeduplicateBatch consider the case of duplicate txs. if the current one under investigation is NOT OK, then we need to check whether there's a previously indexed tx. SKIP the current tx if the previously indexed record is found and successful.

Types

type Batch

type Batch struct {
	Ops []*abci.TxResult
}

Batch groups together multiple Index operations to be performed at the same time. NOTE: Batch is NOT thread-safe and must not be modified after starting its execution.

func NewBatch

func NewBatch(n int64) *Batch

NewBatch creates a new Batch.

func (*Batch) Add

func (b *Batch) Add(result *abci.TxResult) error

Add or update an entry for the given result.Index.

func (*Batch) Size

func (b *Batch) Size() int

Size returns the total number of operations inside the batch.

type IndexerService

type IndexerService struct {
	service.BaseService
	// contains filtered or unexported fields
}

IndexerService connects event bus, transaction and block indexers together in order to index transactions and blocks coming from the event bus.

func NewIndexerService

func NewIndexerService(
	txIdxr TxIndexer,
	blockIdxr indexer.BlockIndexer,
	eventBus *types.EventBus,
) *IndexerService

NewIndexerService returns a new service instance.

func (*IndexerService) OnStart

func (is *IndexerService) OnStart() error

OnStart implements service.Service by subscribing for all transactions and indexing them by events.

func (*IndexerService) OnStop

func (is *IndexerService) OnStop()

OnStop implements service.Service by unsubscribing from all transactions.

type TxIndexer

type TxIndexer interface {
	// AddBatch analyzes, indexes and stores a batch of transactions.
	AddBatch(b *Batch) error

	// Index analyzes, indexes and stores a single transaction.
	Index(result *abci.TxResult) error

	// Get returns the transaction specified by hash or nil if the transaction is not indexed
	// or stored.
	Get(hash []byte) (*abci.TxResult, error)

	// Search allows you to query for transactions.
	Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error)
}

TxIndexer interface defines methods to index and search transactions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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