Documentation ¶
Index ¶
- type BalanceStorageHandler
- func (h *BalanceStorageHandler) AccountsReconciled(ctx context.Context, dbTx database.Transaction, count int) error
- func (h *BalanceStorageHandler) AccountsSeen(ctx context.Context, dbTx database.Transaction, count int) error
- func (h *BalanceStorageHandler) BlockAdded(ctx context.Context, block *types.Block, changes []*parser.BalanceChange) error
- func (h *BalanceStorageHandler) BlockRemoved(ctx context.Context, block *types.Block, changes []*parser.BalanceChange) error
- type BalanceStorageHelper
- func (h *BalanceStorageHelper) AccountBalance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.Amount, error)
- func (h *BalanceStorageHelper) AccountsReconciled(ctx context.Context, dbTx database.Transaction) (*big.Int, error)
- func (h *BalanceStorageHelper) AccountsSeen(ctx context.Context, dbTx database.Transaction) (*big.Int, error)
- func (h *BalanceStorageHelper) Asserter() *asserter.Asserter
- func (h *BalanceStorageHelper) BalanceExemptions() []*types.BalanceExemption
- func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation
- type Client
- type CoinStorageHelper
- 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) GetBalance(ctx context.Context, accountIdentifier *types.AccountIdentifier, ...) (*types.Amount, *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) ([]*lbry.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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceStorageHandler ¶
type BalanceStorageHandler struct{}
BalanceStorageHandler implements storage.BalanceStorageHandler.
func (*BalanceStorageHandler) AccountsReconciled ¶
func (h *BalanceStorageHandler) AccountsReconciled( ctx context.Context, dbTx database.Transaction, count int, ) error
AccountsReconciled updates the total accounts reconciled by count.
func (*BalanceStorageHandler) AccountsSeen ¶
func (h *BalanceStorageHandler) AccountsSeen( ctx context.Context, dbTx database.Transaction, count int, ) error
AccountsSeen updates the total accounts seen by count.
func (*BalanceStorageHandler) BlockAdded ¶
func (h *BalanceStorageHandler) BlockAdded( ctx context.Context, block *types.Block, changes []*parser.BalanceChange, ) error
BlockAdded is called whenever a block is committed to BlockStorage.
func (*BalanceStorageHandler) BlockRemoved ¶
func (h *BalanceStorageHandler) BlockRemoved( ctx context.Context, block *types.Block, changes []*parser.BalanceChange, ) error
BlockRemoved is called whenever a block is removed from BlockStorage.
type BalanceStorageHelper ¶
type BalanceStorageHelper struct {
// contains filtered or unexported fields
}
BalanceStorageHelper implements storage.BalanceStorageHelper.
func (*BalanceStorageHelper) AccountBalance ¶
func (h *BalanceStorageHelper) AccountBalance( ctx context.Context, account *types.AccountIdentifier, currency *types.Currency, block *types.BlockIdentifier, ) (*types.Amount, error)
AccountBalance attempts to fetch the balance for a missing account in storage.
func (*BalanceStorageHelper) AccountsReconciled ¶
func (h *BalanceStorageHelper) AccountsReconciled( ctx context.Context, dbTx database.Transaction, ) (*big.Int, error)
AccountsReconciled returns the total accounts reconciled by count.
func (*BalanceStorageHelper) AccountsSeen ¶
func (h *BalanceStorageHelper) AccountsSeen( ctx context.Context, dbTx database.Transaction, ) (*big.Int, error)
AccountsSeen returns the total accounts seen by count.
func (*BalanceStorageHelper) Asserter ¶
func (h *BalanceStorageHelper) Asserter() *asserter.Asserter
Asserter returns a *asserter.Asserter.
func (*BalanceStorageHelper) BalanceExemptions ¶
func (h *BalanceStorageHelper) BalanceExemptions() []*types.BalanceExemption
BalanceExemptions returns a list of *types.BalanceExemption.
func (*BalanceStorageHelper) ExemptFunc ¶
func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation
ExemptFunc returns a parser.ExemptOperation.
type Client ¶
type Client interface { NetworkStatus(context.Context) (*types.NetworkStatusResponse, error) PruneBlockchain(context.Context, int64) (int64, error) GetRawBlock(context.Context, *types.PartialBlockIdentifier) (*lbry.Block, []string, error) ParseBlock( context.Context, *lbry.Block, map[string]*types.AccountCoin, ) (*types.Block, error) }
Client is used by the indexer to sync blocks.
type CoinStorageHelper ¶
type CoinStorageHelper struct {
// contains filtered or unexported fields
}
CoinStorageHelper implements storage.CoinStorageHelper.
func (*CoinStorageHelper) CurrentBlockIdentifier ¶
func (h *CoinStorageHelper) CurrentBlockIdentifier( ctx context.Context, transaction database.Transaction, ) (*types.BlockIdentifier, error)
CurrentBlockIdentifier returns the current head block identifier and is used to comply with the CoinStorageHelper interface.
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, ) (*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) GetBalance ¶
func (i *Indexer) GetBalance( ctx context.Context, accountIdentifier *types.AccountIdentifier, currency *types.Currency, blockIdentifier *types.PartialBlockIdentifier, ) (*types.Amount, *types.BlockIdentifier, error)
GetBalance returns the balance of an account at a particular *types.PartialBlockIdentifier.
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, ) ([]*lbry.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.