indexer

package
v0.0.7-0...-0581f6b Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

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

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

func (i *Indexer) BlockAdded(ctx context.Context, block *types.Block) error

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

func (i *Indexer) CloseDatabase(ctx context.Context)

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.

func (*Indexer) Prune

func (i *Indexer) Prune(ctx context.Context) error

Prune attempts to prune blocks in lbrycrdd every pruneFrequency.

func (*Indexer) Sync

func (i *Indexer) Sync(ctx context.Context) error

Sync attempts to index lbry blocks using the lbry.Client until stopped.

Jump to

Keyboard shortcuts

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