Documentation ¶
Index ¶
- Constants
- type Client
- type Indexer
- func (i *Indexer) Block(ctx context.Context, network *types.NetworkIdentifier, ...) (*types.Block, error)
- func (i *Indexer) BlockAdded(ctx context.Context, block *types.Block) error
- func (i *Indexer) BlockRemoved(ctx context.Context, blockIdentifier *types.BlockIdentifier) error
- func (i *Indexer) CloseDatabase(ctx context.Context)
- func (i *Indexer) CurrentBlockIdentifier(ctx context.Context, transaction storage.DatabaseTransaction) (*types.BlockIdentifier, error)
- func (i *Indexer) GetBlockLazy(ctx context.Context, blockIdentifier *types.PartialBlockIdentifier) (*types.BlockResponse, error)
- func (i *Indexer) GetBlockTransaction(ctx context.Context, blockIdentifier *types.BlockIdentifier, ...) (*types.Transaction, error)
- func (i *Indexer) GetCoins(ctx context.Context, accountIdentifier *types.AccountIdentifier) ([]*types.Coin, *types.BlockIdentifier, error)
- func (i *Indexer) GetScriptPubKeys(ctx context.Context, coins []*types.Coin) ([]*bitcoin.ScriptPubKey, error)
- func (i *Indexer) NetworkStatus(ctx context.Context, network *types.NetworkIdentifier) (*types.NetworkStatusResponse, error)
- func (i *Indexer) Prune(ctx context.Context) error
- func (i *Indexer) Sync(ctx context.Context) error
Constants ¶
const ( // DefaultIndexCacheSize is the default size of the indexer cache. The larger // the index cache size, the better the performance. DefaultIndexCacheSize = 1 << 30 // 5 GB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { NetworkStatus(context.Context) (*types.NetworkStatusResponse, error) PruneBlockchain(context.Context, int64) (int64, error) GetRawBlock(context.Context, *types.PartialBlockIdentifier) (*bitcoin.Block, []string, error) ParseBlock( context.Context, *bitcoin.Block, map[string]*storage.AccountCoin, ) (*types.Block, error) }
Client is used by the indexer to sync blocks.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer caches blocks and provides balance query functionality.
func Initialize ¶
func Initialize( ctx context.Context, cancel context.CancelFunc, config *configuration.Configuration, client Client, indexCacheSize int64, ) (*Indexer, error)
Initialize returns a new Indexer.
func (*Indexer) Block ¶
func (i *Indexer) Block( ctx context.Context, network *types.NetworkIdentifier, blockIdentifier *types.PartialBlockIdentifier, ) (*types.Block, error)
Block is called by the syncer to fetch a block.
func (*Indexer) BlockAdded ¶
BlockAdded is called by the syncer when a block is added.
func (*Indexer) BlockRemoved ¶
func (i *Indexer) BlockRemoved( ctx context.Context, blockIdentifier *types.BlockIdentifier, ) error
BlockRemoved is called by the syncer when a block is removed.
func (*Indexer) CloseDatabase ¶
CloseDatabase closes a storage.Database. This should be called before exiting.
func (*Indexer) CurrentBlockIdentifier ¶
func (i *Indexer) CurrentBlockIdentifier( ctx context.Context, transaction storage.DatabaseTransaction, ) (*types.BlockIdentifier, error)
CurrentBlockIdentifier returns the current head block identifier and is used to comply with the CoinStorageHelper interface.
func (*Indexer) GetBlockLazy ¶
func (i *Indexer) GetBlockLazy( ctx context.Context, blockIdentifier *types.PartialBlockIdentifier, ) (*types.BlockResponse, error)
GetBlockLazy returns a *types.BlockResponse from the indexer's block storage. All transactions in a block must be fetched individually.
func (*Indexer) GetBlockTransaction ¶
func (i *Indexer) GetBlockTransaction( ctx context.Context, blockIdentifier *types.BlockIdentifier, transactionIdentifier *types.TransactionIdentifier, ) (*types.Transaction, error)
GetBlockTransaction returns a *types.Transaction if it is in the provided *types.BlockIdentifier.
func (*Indexer) GetCoins ¶
func (i *Indexer) GetCoins( ctx context.Context, accountIdentifier *types.AccountIdentifier, ) ([]*types.Coin, *types.BlockIdentifier, error)
GetCoins returns all unspent coins for a particular *types.AccountIdentifier.
func (*Indexer) GetScriptPubKeys ¶
func (i *Indexer) GetScriptPubKeys( ctx context.Context, coins []*types.Coin, ) ([]*bitcoin.ScriptPubKey, error)
GetScriptPubKeys gets the ScriptPubKey for a collection of *types.CoinIdentifier. It also confirms that the amount provided with each coin is valid.
func (*Indexer) NetworkStatus ¶
func (i *Indexer) NetworkStatus( ctx context.Context, network *types.NetworkIdentifier, ) (*types.NetworkStatusResponse, error)
NetworkStatus is called by the syncer to get the current network status.