Documentation ¶
Overview ¶
Package indexers implements optional block DAG indexes.
Index ¶
- func DropAcceptanceIndex(databaseContext *dbaccess.DatabaseContext) error
- type AcceptanceIndex
- func (idx *AcceptanceIndex) ConnectBlock(dbContext *dbaccess.TxContext, blockHash *daghash.Hash, ...) error
- func (idx *AcceptanceIndex) Init(dag *blockdag.BlockDAG, databaseContext *dbaccess.DatabaseContext) error
- func (idx *AcceptanceIndex) TxsAcceptanceData(blockHash *daghash.Hash) (blockdag.MultiBlockTxsAcceptanceData, error)
- type Indexer
- type Manager
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 ¶
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.