datagateway

package
v0.3.0-brc20-1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRuneBalancesParams

type CreateRuneBalancesParams struct {
	PkScript    []byte
	RuneId      runes.RuneId
	Balance     uint128.Uint128
	BlockHeight uint64
}

type IndexerInfoDataGateway

type IndexerInfoDataGateway interface {
	GetLatestIndexerState(ctx context.Context) (entity.IndexerState, error)
	GetLatestIndexerStats(ctx context.Context) (version string, network common.Network, err error)
	SetIndexerState(ctx context.Context, state entity.IndexerState) error
	UpdateIndexerStats(ctx context.Context, clientVersion string, network common.Network) error
}

type RunesDataGateway

type RunesDataGateway interface {
	RunesReaderDataGateway
	RunesWriterDataGateway

	// BeginRunesTx returns a new RunesDataGateway with transaction enabled. All write operations performed in this datagateway must be committed to persist changes.
	BeginRunesTx(ctx context.Context) (RunesDataGatewayWithTx, error)
}

type RunesDataGatewayWithTx

type RunesDataGatewayWithTx interface {
	RunesDataGateway
	Tx
}

type RunesReaderDataGateway

type RunesReaderDataGateway interface {
	GetLatestBlock(ctx context.Context) (types.BlockHeader, error)
	GetIndexedBlockByHeight(ctx context.Context, height int64) (*entity.IndexedBlock, error)
	// GetRuneTransactions returns the runes transactions, filterable by pkScript, runeId and height. If pkScript, runeId or height is zero value, that filter is ignored.
	GetRuneTransactions(ctx context.Context, pkScript []byte, runeId runes.RuneId, height uint64) ([]*entity.RuneTransaction, error)

	GetRunesBalancesAtOutPoint(ctx context.Context, outPoint wire.OutPoint) (map[runes.RuneId]*entity.OutPointBalance, error)
	GetUnspentOutPointBalancesByPkScript(ctx context.Context, pkScript []byte, blockHeight uint64) ([]*entity.OutPointBalance, error)
	// GetRuneIdFromRune returns the RuneId for the given rune. Returns errs.NotFound if the rune entry is not found.
	GetRuneIdFromRune(ctx context.Context, rune runes.Rune) (runes.RuneId, error)
	// GetRuneEntryByRuneId returns the RuneEntry for the given runeId. Returns errs.NotFound if the rune entry is not found.
	GetRuneEntryByRuneId(ctx context.Context, runeId runes.RuneId) (*runes.RuneEntry, error)
	// GetRuneEntryByRuneIdBatch returns the RuneEntries for the given runeIds.
	GetRuneEntryByRuneIdBatch(ctx context.Context, runeIds []runes.RuneId) (map[runes.RuneId]*runes.RuneEntry, error)
	// GetRuneEntryByRuneIdAndHeight returns the RuneEntry for the given runeId and block height. Returns errs.NotFound if the rune entry is not found.
	GetRuneEntryByRuneIdAndHeight(ctx context.Context, runeId runes.RuneId, blockHeight uint64) (*runes.RuneEntry, error)
	// GetRuneEntryByRuneIdAndHeightBatch returns the RuneEntries for the given runeIds and block height.
	GetRuneEntryByRuneIdAndHeightBatch(ctx context.Context, runeIds []runes.RuneId, blockHeight uint64) (map[runes.RuneId]*runes.RuneEntry, error)
	// CountRuneEntries returns the number of existing rune entries.
	CountRuneEntries(ctx context.Context) (uint64, error)

	// GetBalancesByPkScript returns the balances for the given pkScript at the given blockHeight.
	GetBalancesByPkScript(ctx context.Context, pkScript []byte, blockHeight uint64) (map[runes.RuneId]*entity.Balance, error)
	// GetBalancesByRuneId returns the balances for the given runeId at the given blockHeight.
	// Cannot use []byte as map key, so we're returning as slice.
	GetBalancesByRuneId(ctx context.Context, runeId runes.RuneId, blockHeight uint64) ([]*entity.Balance, error)
	// GetBalancesByPkScriptAndRuneId returns the balance for the given pkScript and runeId at the given blockHeight.
	GetBalanceByPkScriptAndRuneId(ctx context.Context, pkScript []byte, runeId runes.RuneId, blockHeight uint64) (*entity.Balance, error)
}

type RunesWriterDataGateway

type RunesWriterDataGateway interface {
	CreateRuneEntry(ctx context.Context, entry *runes.RuneEntry, blockHeight uint64) error
	CreateRuneEntryState(ctx context.Context, entry *runes.RuneEntry, blockHeight uint64) error
	CreateOutPointBalances(ctx context.Context, outPointBalances []*entity.OutPointBalance) error
	SpendOutPointBalances(ctx context.Context, outPoint wire.OutPoint, blockHeight uint64) error
	CreateRuneBalances(ctx context.Context, params []CreateRuneBalancesParams) error
	CreateRuneTransaction(ctx context.Context, tx *entity.RuneTransaction) error
	CreateIndexedBlock(ctx context.Context, block *entity.IndexedBlock) error

	// TODO: collapse these into a single function (ResetStateToHeight)?
	DeleteIndexedBlockSinceHeight(ctx context.Context, height uint64) error
	DeleteRuneEntriesSinceHeight(ctx context.Context, height uint64) error
	DeleteRuneEntryStatesSinceHeight(ctx context.Context, height uint64) error
	DeleteRuneTransactionsSinceHeight(ctx context.Context, height uint64) error
	DeleteRunestonesSinceHeight(ctx context.Context, height uint64) error
	DeleteOutPointBalancesSinceHeight(ctx context.Context, height uint64) error
	UnspendOutPointBalancesSinceHeight(ctx context.Context, height uint64) error
	DeleteRuneBalancesSinceHeight(ctx context.Context, height uint64) error
}

type Tx

type Tx interface {
	// Commit commits the DB transaction. All changes made after Begin() will be persisted. Calling Commit() will close the current transaction.
	// If Commit() is called without a prior Begin(), it must be a no-op.
	Commit(ctx context.Context) error
	// Rollback rolls back the DB transaction. All changes made after Begin() will be discarded.
	// Rollback() must be safe to call even if no transaction is active. Hence, a defer Rollback() is safe, even if Commit() was called prior with non-error conditions.
	Rollback(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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