Documentation ¶
Overview ¶
Package indexers implements optional block chain indexes.
Index ¶
- func DisableLog()
- func DropAddrIndex(db database.DB, interrupt <-chan struct{}) error
- func DropCfIndex(db database.DB, interrupt <-chan struct{}) error
- func DropSlpIndex(db database.DB, interrupt <-chan struct{}) error
- func DropTxIndex(db database.DB, interrupt <-chan struct{}) error
- func TopologicallySortTxs(transactions []*bchutil.Tx) []*wire.MsgTx
- func UseLogger(logger bchlog.Logger)
- type AddTxIndexEntryHandler
- type AddrIndex
- func (idx *AddrIndex) AddUnconfirmedTx(tx *bchutil.Tx, utxoView *blockchain.UtxoViewpoint)
- func (idx *AddrIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *AddrIndex) Create(dbTx database.Tx) error
- func (idx *AddrIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *AddrIndex) Init() error
- func (idx *AddrIndex) Key() []byte
- func (idx *AddrIndex) Migrate(db database.DB, interrupt <-chan struct{}) error
- func (idx *AddrIndex) Name() string
- func (idx *AddrIndex) NeedsInputs() bool
- func (idx *AddrIndex) RemoveUnconfirmedTx(hash *chainhash.Hash)
- func (idx *AddrIndex) StartBlock() (*chainhash.Hash, int32)
- func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr bchutil.Address, numToSkip, numRequested uint32, ...) ([]database.BlockRegion, uint32, error)
- func (idx *AddrIndex) UnconfirmedTxnsForAddress(addr bchutil.Address) []*bchutil.Tx
- type AssertError
- type BurnedInput
- type CfIndex
- func (idx *CfIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *CfIndex) Create(dbTx database.Tx) error
- func (idx *CfIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, _ []blockchain.SpentTxOut) error
- func (idx *CfIndex) FilterByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
- func (idx *CfIndex) FilterHashByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
- func (idx *CfIndex) FilterHashesByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
- func (idx *CfIndex) FilterHeaderByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
- func (idx *CfIndex) FilterHeadersByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
- func (idx *CfIndex) FiltersByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
- func (idx *CfIndex) Init() error
- func (idx *CfIndex) Key() []byte
- func (idx *CfIndex) Migrate(db database.DB, interrupt <-chan struct{}) error
- func (idx *CfIndex) Name() string
- func (idx *CfIndex) NeedsInputs() bool
- func (idx *CfIndex) StartBlock() (*chainhash.Hash, int32)
- type GetSlpIndexEntryHandler
- type Indexer
- type Manager
- func (m *Manager) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (m *Manager) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxo []blockchain.SpentTxOut) error
- func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{}) error
- type NeedsInputser
- type SlpCache
- func (s *SlpCache) AddMempoolSlpTxEntry(hash *chainhash.Hash, item SlpTxEntry)
- func (s *SlpCache) AddSlpTxEntry(hash *chainhash.Hash, item SlpTxEntry) error
- func (s *SlpCache) AddTempTokenMetadata(item TokenMetadata) error
- func (s *SlpCache) ForEachMempoolItem(fnc func(hash *chainhash.Hash, entry *SlpTxEntry) error) error
- func (s *SlpCache) GetMempoolItem(hash *chainhash.Hash) *SlpTxEntry
- func (s *SlpCache) GetSlpTxEntry(hash *chainhash.Hash) (SlpTxEntry, bool)
- func (s *SlpCache) GetTokenMetadata(hash *chainhash.Hash) (TokenMetadata, bool)
- func (s *SlpCache) MempoolSize() int
- func (s *SlpCache) RemoveMempoolSlpTxItems(txs []*bchutil.Tx)
- func (s *SlpCache) RemoveTokenMetadata(hash chainhash.Hash)
- type SlpConfig
- type SlpIndex
- func (idx *SlpIndex) AddGraphSearchTxn(tx *wire.MsgTx)
- func (idx *SlpIndex) AddPotentialSlpEntries(dbTx database.Tx, msgTx *wire.MsgTx) (bool, error)
- func (idx *SlpIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *SlpIndex) Create(dbTx database.Tx) error
- func (idx *SlpIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *SlpIndex) GetGraphSearchDb() (*slpgraphsearch.Db, error)
- func (idx *SlpIndex) GetSlpIndexEntry(dbTx database.Tx, hash *chainhash.Hash) (*SlpTxEntry, error)
- func (idx *SlpIndex) GetTokenMetadata(dbTx database.Tx, entry *SlpTxEntry) (*TokenMetadata, error)
- func (idx *SlpIndex) GraphSearchEnabled() bool
- func (idx *SlpIndex) Init() error
- func (idx *SlpIndex) Key() []byte
- func (idx *SlpIndex) LoadSlpGraphSearchDb(fetchTxn func(txnHash *chainhash.Hash) ([]byte, error), initWg *sync.WaitGroup, ...)
- func (idx *SlpIndex) Migrate(db database.DB, interrupt <-chan struct{}) error
- func (idx *SlpIndex) Name() string
- func (idx *SlpIndex) StartBlock() (*chainhash.Hash, int32)
- type SlpTxEntry
- type TokenMetadata
- type TxIndex
- func (idx *TxIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *TxIndex) Create(dbTx database.Tx) error
- func (idx *TxIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
- func (idx *TxIndex) Init() error
- func (idx *TxIndex) Key() []byte
- func (idx *TxIndex) Migrate(db database.DB, interrupt <-chan struct{}) error
- func (idx *TxIndex) Name() string
- func (idx *TxIndex) StartBlock() (*chainhash.Hash, int32)
- func (idx *TxIndex) TxBlockRegion(hash *chainhash.Hash) (*database.BlockRegion, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func DropAddrIndex ¶
DropAddrIndex drops the address index from the provided database if it exists.
func DropCfIndex ¶
DropCfIndex drops the CF index from the provided database if exists.
func DropSlpIndex ¶
DropSlpIndex drops the transaction index from the provided database if it exists. Since the address index relies on it, the address index will also be dropped when it exists.
func DropTxIndex ¶
DropTxIndex drops the transaction index from the provided database if it exists. Since the address index relies on it, the address index will also be dropped when it exists.
func TopologicallySortTxs ¶
TopologicallySortTxs sorts a list of transactions into topological order. That is, the child transactions come after parents.
Types ¶
type AddTxIndexEntryHandler ¶
AddTxIndexEntryHandler provides a function interface for CheckSlpTx
type AddrIndex ¶
type AddrIndex struct {
// contains filtered or unexported fields
}
AddrIndex implements a transaction by address index. That is to say, it supports querying all transactions that reference a given address because they are either crediting or debiting the address. The returned transactions are ordered according to their order of appearance in the blockchain. In other words, first by block height and then by offset inside the block.
In addition, support is provided for a memory-only index of unconfirmed transactions such as those which are kept in the memory pool before inclusion in a block.
func NewAddrIndex ¶
NewAddrIndex returns a new instance of an indexer that is used to create a mapping of all addresses in the blockchain to the respective transactions that involve them.
It implements the Indexer interface which plugs into the IndexManager that in turn is used by the blockchain package. This allows the index to be seamlessly maintained along with the chain.
func (*AddrIndex) AddUnconfirmedTx ¶
func (idx *AddrIndex) AddUnconfirmedTx(tx *bchutil.Tx, utxoView *blockchain.UtxoViewpoint)
AddUnconfirmedTx adds all addresses related to the transaction to the unconfirmed (memory-only) address index.
NOTE: This transaction MUST have already been validated by the memory pool before calling this function with it and have all of the inputs available in the provided utxo view. Failure to do so could result in some or all addresses not being indexed.
This function is safe for concurrent access.
func (*AddrIndex) ConnectBlock ¶
func (idx *AddrIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
ConnectBlock is invoked by the index manager when a new block has been connected to the main chain. This indexer adds a mapping for each address the transactions in the block involve.
This is part of the Indexer interface.
func (*AddrIndex) Create ¶
Create is invoked when the indexer manager determines the index needs to be created for the first time. It creates the bucket for the address index.
This is part of the Indexer interface.
func (*AddrIndex) DisconnectBlock ¶
func (idx *AddrIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
DisconnectBlock is invoked by the index manager when a block has been disconnected from the main chain. This indexer removes the address mappings each transaction in the block involve.
This is part of the Indexer interface.
func (*AddrIndex) Init ¶
Init is only provided to satisfy the Indexer interface as there is nothing to initialize for this index.
This is part of the Indexer interface.
func (*AddrIndex) Key ¶
Key returns the database key to use for the index as a byte slice.
This is part of the Indexer interface.
func (*AddrIndex) Migrate ¶
Migrate is only provided to satisfy the Indexer interface as there is nothing to migrate this index.
This is part of the Indexer interface.
func (*AddrIndex) Name ¶
Name returns the human-readable name of the index.
This is part of the Indexer interface.
func (*AddrIndex) NeedsInputs ¶
NeedsInputs signals that the index requires the referenced inputs in order to properly create the index.
This implements the NeedsInputser interface.
func (*AddrIndex) RemoveUnconfirmedTx ¶
RemoveUnconfirmedTx removes the passed transaction from the unconfirmed (memory-only) address index.
This function is safe for concurrent access.
func (*AddrIndex) StartBlock ¶
StartBlock is used to indicate the proper start block for the index manager.
This is part of the Indexer interface.
func (*AddrIndex) TxRegionsForAddress ¶
func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr bchutil.Address, numToSkip, numRequested uint32, reverse bool) ([]database.BlockRegion, uint32, error)
TxRegionsForAddress returns a slice of block regions which identify each transaction that involves the passed address according to the specified number to skip, number requested, and whether or not the results should be reversed. It also returns the number actually skipped since it could be less in the case where there are not enough entries.
NOTE: These results only include transactions confirmed in blocks. See the UnconfirmedTxnsForAddress method for obtaining unconfirmed transactions that involve a given address.
This function is safe for concurrent access.
func (*AddrIndex) UnconfirmedTxnsForAddress ¶
UnconfirmedTxnsForAddress returns all transactions currently in the unconfirmed (memory-only) address index that involve the passed address. Unsupported address types are ignored and will result in no results.
This function is safe for concurrent access.
type AssertError ¶
type AssertError string
AssertError identifies an error that indicates an internal code consistency issue and should be treated as a critical and unrecoverable error.
func (AssertError) Error ¶
func (e AssertError) Error() string
Error returns the assertion error as a huma-readable string and satisfies the error interface.
type BurnedInput ¶
type BurnedInput struct { Tx *wire.MsgTx TxInput *wire.TxIn SlpMsg v1parser.ParseResult Entry *SlpTxEntry }
BurnedInput represents a burned slp txo item
func CheckSlpTx ¶
func CheckSlpTx(tx *wire.MsgTx, getSlpIndexEntry GetSlpIndexEntryHandler, putTxIndexEntry AddTxIndexEntryHandler) (bool, []*BurnedInput, error)
CheckSlpTx checks a transaction for validity and adds valid transactions to the db
type CfIndex ¶
type CfIndex struct {
// contains filtered or unexported fields
}
CfIndex implements a committed filter (cf) by hash index.
func NewCfIndex ¶
NewCfIndex returns a new instance of an indexer that is used to create a mapping of the hashes of all blocks in the blockchain to their respective committed filters.
It implements the Indexer interface which plugs into the IndexManager that in turn is used by the blockchain package. This allows the index to be seamlessly maintained along with the chain.
func (*CfIndex) ConnectBlock ¶
func (idx *CfIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
ConnectBlock is invoked by the index manager when a new block has been connected to the main chain. This indexer adds a hash-to-cf mapping for every passed block. This is part of the Indexer interface.
func (*CfIndex) Create ¶
Create is invoked when the indexer manager determines the index needs to be created for the first time. It creates buckets for the two hash-based cf indexes (regular only currently).
func (*CfIndex) DisconnectBlock ¶
func (idx *CfIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, _ []blockchain.SpentTxOut) error
DisconnectBlock is invoked by the index manager when a block has been disconnected from the main chain. This indexer removes the hash-to-cf mapping for every passed block. This is part of the Indexer interface.
func (*CfIndex) FilterByBlockHash ¶
func (idx *CfIndex) FilterByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
FilterByBlockHash returns the serialized contents of a block's basic or committed filter.
func (*CfIndex) FilterHashByBlockHash ¶
func (idx *CfIndex) FilterHashByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
FilterHashByBlockHash returns the serialized contents of a block's basic committed filter hash.
func (*CfIndex) FilterHashesByBlockHashes ¶
func (idx *CfIndex) FilterHashesByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
FilterHashesByBlockHashes returns the serialized contents of a block's basic committed filter hash for a set of blocks by hash.
func (*CfIndex) FilterHeaderByBlockHash ¶
func (idx *CfIndex) FilterHeaderByBlockHash(h *chainhash.Hash, filterType wire.FilterType) ([]byte, error)
FilterHeaderByBlockHash returns the serialized contents of a block's basic committed filter header.
func (*CfIndex) FilterHeadersByBlockHashes ¶
func (idx *CfIndex) FilterHeadersByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
FilterHeadersByBlockHashes returns the serialized contents of a block's basic committed filter header for a set of blocks by hash.
func (*CfIndex) FiltersByBlockHashes ¶
func (idx *CfIndex) FiltersByBlockHashes(blockHashes []*chainhash.Hash, filterType wire.FilterType) ([][]byte, error)
FiltersByBlockHashes returns the serialized contents of a block's basic or committed filter for a set of blocks by hash.
func (*CfIndex) Init ¶
Init initializes the hash-based cf index. This is part of the Indexer interface.
func (*CfIndex) Key ¶
Key returns the database key to use for the index as a byte slice. This is part of the Indexer interface.
func (*CfIndex) Migrate ¶
Migrate migrates the index up to the current version. For the CfIndex we will just drop the index here and write the new version number. The IndexManager will then rebuild the index from the blockchain, using the new scheme, as it continues its Init function.
This is part of the Indexer interface.
func (*CfIndex) Name ¶
Name returns the human-readable name of the index. This is part of the Indexer interface.
func (*CfIndex) NeedsInputs ¶
NeedsInputs signals that the index requires the referenced inputs in order to properly create the index.
This implements the NeedsInputser interface.
type GetSlpIndexEntryHandler ¶
type GetSlpIndexEntryHandler func(*chainhash.Hash) (*SlpTxEntry, error)
GetSlpIndexEntryHandler provides a function interface for CheckSlpTx
type Indexer ¶
type Indexer interface { // Key returns the key of the index as a byte slice. Key() []byte // Name returns the human-readable name of the index. Name() string // Create is invoked when the indexer manager determines the index needs // to be created for the first time. Create(dbTx database.Tx) error // Migrate is invoked after Init and allows each index the opportunity // to perform any migrations as necessary. This should be a noop if // there are no migrations to perform. Migrate(db database.DB, interrupt <-chan struct{}) error // Init is invoked when the index manager is first initializing the // index. This differs from the Create method in that it is called on // every load, including the case the index was just created. Init() error // ConnectBlock is invoked when a new block has been connected to the // main chain. The set of output spent within a block is also passed in // so indexers can access the pevious output scripts input spent if // required. ConnectBlock(database.Tx, *bchutil.Block, []blockchain.SpentTxOut) error // DisconnectBlock is invoked when a block has been disconnected from // the main chain. The set of outputs scripts that were spent within // this block is also returned so indexers can clean up the prior index // state for this block DisconnectBlock(database.Tx, *bchutil.Block, []blockchain.SpentTxOut) error // StartBlock is invoked to get which block the indexer should be // started from. The first indexed height is after this block, and the // block hash returned here is compared against the first indexed block's // previous block hash. StartBlock() (hash *chainhash.Hash, height int32) }
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 blockchain.IndexManager interface so it can be seamlessly plugged into normal chain processing.
func NewManager ¶
NewManager returns a new index manager with the provided indexes enabled.
The manager returned satisfies the blockchain.IndexManager interface and thus cleanly plugs into the normal blockchain processing path.
func (*Manager) ConnectBlock ¶
func (m *Manager) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
ConnectBlock must be invoked when a block is extending the main chain. 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 blockchain.IndexManager interface.
func (*Manager) DisconnectBlock ¶
func (m *Manager) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxo []blockchain.SpentTxOut) error
DisconnectBlock must be invoked when a block is being disconnected from the end of the main chain. It keeps track of the state of each index it is managing, performs some sanity checks, and invokes each indexer to remove the index entries associated with the block.
This is part of the blockchain.IndexManager interface.
func (*Manager) Init ¶
func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{}) error
Init initializes the enabled indexes. This is called during chain initialization and primarily consists of catching up all indexes to the current best chain tip. This is necessary since each index can be disabled and re-enabled at any time and attempting to catch-up indexes at the same time new blocks are being downloaded would lead to an overall longer time to catch up due to the I/O contention.
This is part of the blockchain.IndexManager interface.
type NeedsInputser ¶
type NeedsInputser interface {
NeedsInputs() bool
}
NeedsInputser provides a generic interface for an indexer to specify the it requires the ability to look up inputs for a transaction.
type SlpCache ¶
SlpCache to manage slp index mempool inventory and recently queried slp index entries and token metadata items. The RWMutex lock is held for mempoolSlpTxEntries operations since gcache.Cache holds its own locks.
func InitSlpCache ¶
InitSlpCache creates a new instance of SlpCache
func (*SlpCache) AddMempoolSlpTxEntry ¶
func (s *SlpCache) AddMempoolSlpTxEntry(hash *chainhash.Hash, item SlpTxEntry)
AddMempoolSlpTxEntry puts new items in the mempool cache
func (*SlpCache) AddSlpTxEntry ¶
func (s *SlpCache) AddSlpTxEntry(hash *chainhash.Hash, item SlpTxEntry) error
AddSlpTxEntry puts new items in a temporary cache with limited size
func (*SlpCache) AddTempTokenMetadata ¶
func (s *SlpCache) AddTempTokenMetadata(item TokenMetadata) error
AddTempTokenMetadata puts token metadata into cache with a limited size
func (*SlpCache) ForEachMempoolItem ¶
func (s *SlpCache) ForEachMempoolItem(fnc func(hash *chainhash.Hash, entry *SlpTxEntry) error) error
ForEachMempoolItem provides thread-safe access to all mempool entries
func (*SlpCache) GetMempoolItem ¶
func (s *SlpCache) GetMempoolItem(hash *chainhash.Hash) *SlpTxEntry
GetMempoolItem gets items from only mempool entries
func (*SlpCache) GetSlpTxEntry ¶
func (s *SlpCache) GetSlpTxEntry(hash *chainhash.Hash) (SlpTxEntry, bool)
GetSlpTxEntry gets tx entry items from the cache
func (*SlpCache) GetTokenMetadata ¶
func (s *SlpCache) GetTokenMetadata(hash *chainhash.Hash) (TokenMetadata, bool)
GetTokenMetadata gets token metadata from the cache
func (*SlpCache) MempoolSize ¶
MempoolSize returns the size of the slp mempool cache
func (*SlpCache) RemoveMempoolSlpTxItems ¶
RemoveMempoolSlpTxItems is called on block events to remove mempool transaction items and also we clear the tempTokenMetadata to avoid corrupt mint baton state from double spends
func (*SlpCache) RemoveTokenMetadata ¶
RemoveTokenMetadata removes a token metadata item from cache
type SlpConfig ¶
type SlpConfig struct { StartHash *chainhash.Hash StartHeight int32 AddrPrefix string MaxCacheSize int SlpGraphSearchEnabled bool }
SlpConfig provides the proper starting height and hash
type SlpIndex ¶
type SlpIndex struct {
// contains filtered or unexported fields
}
SlpIndex implements a transaction by hash index. That is to say, it supports querying all transactions by their hash.
func NewSlpIndex ¶
NewSlpIndex returns a new instance of an indexer that is used to create a mapping of the hashes of all slp transactions in the blockchain to the respective token ID, and token metadata.
It implements the Indexer interface which plugs into the IndexManager that in turn is used by the blockchain package. This allows the index to be seamlessly maintained along with the chain.
func (*SlpIndex) AddGraphSearchTxn ¶
AddGraphSearchTxn adds a transaction to graph search.
func (*SlpIndex) AddPotentialSlpEntries ¶
AddPotentialSlpEntries checks if a transaction is slp valid and then will add a new SlpIndexEntry to the shared cache of valid slp transactions.
This method should be used to assess slp validity of newly received mempool items and also in rpc client subscriber methods that return notifications for both mempool and block events to prevent any possibility of a race conditions with manageSlpEntryCache.
func (*SlpIndex) ConnectBlock ¶
func (idx *SlpIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
ConnectBlock is invoked by the index manager when a new block has been connected to the main chain. This indexer adds a hash-to-transaction mapping for every transaction in the passed block.
This is part of the Indexer interface.
func (*SlpIndex) Create ¶
Create is invoked when the indexer manager determines the index needs to be created for the first time. It creates the buckets for the hash-based transaction index and the internal token ID and token metadata indexes.
This is part of the Indexer interface.
func (*SlpIndex) DisconnectBlock ¶
func (idx *SlpIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
DisconnectBlock is invoked by the index manager when a block has been disconnected from the main chain. This indexer removes the hash-to-transaction mapping for every transaction in the block.
This is part of the Indexer interface.
func (*SlpIndex) GetGraphSearchDb ¶
func (idx *SlpIndex) GetGraphSearchDb() (*slpgraphsearch.Db, error)
GetGraphSearchDb checks if graph search is enabled and returns the db
func (*SlpIndex) GetSlpIndexEntry ¶
GetSlpIndexEntry returns a serialized slp index entry for the provided transaction hash from the slp index. The slp index entry can in turn be used to quickly discover additional slp information about the transaction. When there is no entry for the provided hash, nil will be returned for the both the entry and the error, which would mean the transaction is invalid
This function is safe for concurrent access.
func (*SlpIndex) GetTokenMetadata ¶
func (idx *SlpIndex) GetTokenMetadata(dbTx database.Tx, entry *SlpTxEntry) (*TokenMetadata, error)
GetTokenMetadata fetches token metadata properties from an SlpIndexEntry
func (*SlpIndex) GraphSearchEnabled ¶
GraphSearchEnabled indicates if slp graph search is enabled
func (*SlpIndex) Init ¶
Init initializes the hash-based slp transaction index. In particular, it finds the highest used Token ID and stores it for later use when a new token has been created.
This is part of the Indexer interface.
func (*SlpIndex) Key ¶
Key returns the database key to use for the index as a byte slice.
This is part of the Indexer interface.
func (*SlpIndex) LoadSlpGraphSearchDb ¶
func (idx *SlpIndex) LoadSlpGraphSearchDb(fetchTxn func(txnHash *chainhash.Hash) ([]byte, error), initWg *sync.WaitGroup, interupt *int32)
LoadSlpGraphSearchDb is used to load data needed for slp graph search
NOTE: this is launched as a goroutine and does not return errors!
func (*SlpIndex) Migrate ¶
Migrate is only provided to satisfy the Indexer interface as there is nothing to migrate this index.
This is part of the Indexer interface.
type SlpTxEntry ¶
type SlpTxEntry struct { TokenID uint32 TokenIDHash chainhash.Hash SlpVersionType v1parser.TokenType SlpOpReturn []byte }
SlpTxEntry is a valid slp token stored in the slp index
type TokenMetadata ¶
type TokenMetadata struct { TokenID *chainhash.Hash SlpVersion v1parser.TokenType NftGroupID *chainhash.Hash MintBatonHash *chainhash.Hash MintBatonVout uint32 }
TokenMetadata is used to hold the unmarshalled data parsed from the Token ID index
type TxIndex ¶
type TxIndex struct {
// contains filtered or unexported fields
}
TxIndex implements a transaction by hash index. That is to say, it supports querying all transactions by their hash.
func NewTxIndex ¶
NewTxIndex returns a new instance of an indexer that is used to create a mapping of the hashes of all transactions in the blockchain to the respective block, location within the block, and size of the transaction.
It implements the Indexer interface which plugs into the IndexManager that in turn is used by the blockchain package. This allows the index to be seamlessly maintained along with the chain.
func (*TxIndex) ConnectBlock ¶
func (idx *TxIndex) ConnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
ConnectBlock is invoked by the index manager when a new block has been connected to the main chain. This indexer adds a hash-to-transaction mapping for every transaction in the passed block.
This is part of the Indexer interface.
func (*TxIndex) Create ¶
Create is invoked when the indexer manager determines the index needs to be created for the first time. It creates the buckets for the hash-based transaction index and the internal block ID indexes.
This is part of the Indexer interface.
func (*TxIndex) DisconnectBlock ¶
func (idx *TxIndex) DisconnectBlock(dbTx database.Tx, block *bchutil.Block, stxos []blockchain.SpentTxOut) error
DisconnectBlock is invoked by the index manager when a block has been disconnected from the main chain. This indexer removes the hash-to-transaction mapping for every transaction in the block.
This is part of the Indexer interface.
func (*TxIndex) Init ¶
Init initializes the hash-based transaction index. In particular, it finds the highest used block ID and stores it for later use when connecting or disconnecting blocks.
This is part of the Indexer interface.
func (*TxIndex) Key ¶
Key returns the database key to use for the index as a byte slice.
This is part of the Indexer interface.
func (*TxIndex) Migrate ¶
Migrate is only provided to satisfy the Indexer interface as there is nothing to migrate this index.
This is part of the Indexer interface.
func (*TxIndex) Name ¶
Name returns the human-readable name of the index.
This is part of the Indexer interface.
func (*TxIndex) StartBlock ¶
StartBlock is used to indicate the proper start block for the index manager.
This is part of the Indexer interface.
func (*TxIndex) TxBlockRegion ¶
TxBlockRegion returns the block region for the provided transaction hash from the transaction index. The block region can in turn be used to load the raw transaction bytes. When there is no entry for the provided hash, nil will be returned for the both the entry and the error.
This function is safe for concurrent access.