indexers

package
v0.6.4-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: ISC Imports: 8 Imported by: 0

README

indexers

ISC License GoDoc

Package indexers implements optional block chain indexes.

These indexes are typically used to enhance the amount of information available via an RPC interface.

Supported Indexers

  • Transaction-by-hash (txindex) Index
    • Creates a mapping from the hash of each transaction to the block that contains it along with its offset and length within the serialized block
  • Transaction-by-address (addrindex) Index
    • Creates a mapping from every address to all transactions which either credit or debit the address
    • Requires the transaction-by-hash index
  • AcceptanceData-by-block Index
    • Creates a mapping from the hash of each block to the list of transaction this block accepts from it's .Blues

Documentation

Overview

Package indexers implements optional block DAG indexes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropAcceptanceIndex

func DropAcceptanceIndex(databaseContext *dbaccess.DatabaseContext) error

DropAcceptanceIndex drops the acceptance index.

Types

type AcceptanceIndex

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

AcceptanceIndex implements a txAcceptanceData by block hash index. That is to say, it stores a mapping between a block's hash and the set of transactions that the block accepts among its blue blocks.

func NewAcceptanceIndex

func NewAcceptanceIndex() *AcceptanceIndex

NewAcceptanceIndex returns a new instance of an indexer that is used to create a mapping between block hashes and their txAcceptanceData.

It implements the Indexer interface which plugs into the IndexManager that in turn is used by the blockdag package. This allows the index to be seamlessly maintained along with the DAG.

func (*AcceptanceIndex) ConnectBlock

func (idx *AcceptanceIndex) ConnectBlock(dbContext *dbaccess.TxContext, blockHash *daghash.Hash,
	txsAcceptanceData blockdag.MultiBlockTxsAcceptanceData) error

ConnectBlock is invoked by the index manager when a new block has been connected to the DAG.

This is part of the Indexer interface.

func (*AcceptanceIndex) Init

func (idx *AcceptanceIndex) Init(dag *blockdag.BlockDAG, databaseContext *dbaccess.DatabaseContext) error

Init initializes the hash-based acceptance index.

This is part of the Indexer interface.

func (*AcceptanceIndex) TxsAcceptanceData

func (idx *AcceptanceIndex) TxsAcceptanceData(blockHash *daghash.Hash) (blockdag.MultiBlockTxsAcceptanceData, error)

TxsAcceptanceData returns the acceptance data of all the transactions that were accepted by the block with hash blockHash.

type Indexer

type Indexer interface {
	// Init is invoked when the index manager is first initializing the
	// index.
	Init(dag *blockdag.BlockDAG, databaseContext *dbaccess.DatabaseContext) error

	// ConnectBlock is invoked when the index manager is notified that a new
	// block has been connected to the DAG.
	ConnectBlock(dbContext *dbaccess.TxContext,
		blockHash *daghash.Hash,
		acceptedTxsData blockdag.MultiBlockTxsAcceptanceData) error
}

Indexer provides a generic interface for an indexer that is managed by an index manager such as the Manager type provided by this package.

type Manager

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

Manager defines an index manager that manages multiple optional indexes and implements the blockdag.IndexManager interface so it can be seamlessly plugged into normal DAG processing.

func NewManager

func NewManager(enabledIndexes []Indexer) *Manager

NewManager returns a new index manager with the provided indexes enabled.

The manager returned satisfies the blockdag.IndexManager interface and thus cleanly plugs into the normal blockdag processing path.

func (*Manager) ConnectBlock

func (m *Manager) ConnectBlock(dbContext *dbaccess.TxContext, blockHash *daghash.Hash, txsAcceptanceData blockdag.MultiBlockTxsAcceptanceData) error

ConnectBlock must be invoked when a block is added to the DAG. It keeps track of the state of each index it is managing, performs some sanity checks, and invokes each indexer.

This is part of the blockdag.IndexManager interface.

func (*Manager) Init

func (m *Manager) Init(dag *blockdag.BlockDAG, databaseContext *dbaccess.DatabaseContext) error

Init initializes the enabled indexes. This is part of the blockdag.IndexManager interface.

Jump to

Keyboard shortcuts

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