sqlstore

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package sqlstore contains the shared database/sql metadata store.

Index

Constants

View Source
const LatestPoolOpCertSequencesSQL = `
SELECT pool_key_hash, MAX(sequence)
FROM pool_opcert_sequence
GROUP BY pool_key_hash`

LatestPoolOpCertSequencesSQL is the statement LatestPoolOpCertSequences issues.

Exported so a test can pin its query plan against the statement the store actually runs. The index this reads is only worth its write cost while the planner chooses it, and a test EXPLAINing a hand-copied statement would keep passing against the copy after the store's own SQL moved off the index.

Variables

This section is empty.

Functions

func CreateDirDurable added in v0.70.0

func CreateDirDurable(dir string) error

CreateDirDurable is os.MkdirAll(dir, 0o755), but additionally fsyncs the parent of every directory component it actually had to create, so each new directory's own entry is durable -- not just, per a subsequent file write's own directory-sync, the eventual contents placed inside it. A directory's fsync only guarantees ITS children's directory entries are persisted; a power loss right after mkdir could otherwise leave the newly created directory itself unreachable (or entirely absent) from its parent after a crash, even though a file was safely and durably written inside it a moment later.

func OpenDB

func OpenDB(driverName, dataSourceName, systemName string) (*sql.DB, error)

OpenDB opens an instrumented database/sql pool. Keeping driver wrapping in the shared package gives every provider the same query and transaction tracing behavior.

func PublishBackupFile added in v0.70.0

func PublishBackupFile(
	dstPath string,
	write func(stagedPath string) error,
) (err error)

PublishBackupFile runs write against a path inside a private, uniquely named staging directory next to dstPath, then publishes the result to dstPath (which must not already exist) with an os.Link and fsyncs dstDir so the link is durable, not just atomic.

Every dump-producing metadata backend (sqlite's VACUUM INTO, postgres's pg_dump, mysql's mysqldump) needs the exact same crash-safety shape: the dump tool must never write dstPath directly, because a failed or cancelled dump would then require deleting dstPath to clean up, and an unconditional os.Remove(dstPath) on failure is a TOCTOU race against a concurrent creator that populated dstPath in the window between the existence check and the failure. Staging into a private os.MkdirTemp directory sidesteps that: nothing else can be using that path, and publishing via os.Link (not os.Rename) is itself no-clobber -- it fails if a concurrent creator populated dstPath after the initial check, rather than silently overwriting it.

Types

type Config

type Config struct {
	WriteDB *sql.DB
	ReadDB  *sql.DB
	Dialect Dialect
	Logger  *slog.Logger
	// StorageMode controls retention of API-only transaction detail. Empty
	// selects the consensus-focused core mode.
	StorageMode string

	Migrations      []migrations.Migration
	MigrationLocker migrations.Locker
	DiskSize        func() (int64, error)
	// Maintenance is optional backend maintenance started only after the
	// migration readiness gate succeeds. SQLite uses it for periodic VACUUM.
	Maintenance         func(context.Context) error
	MaintenanceInterval time.Duration
	// BackupTo and RestoreFrom are optional provider-owned lifecycle hooks.
	// SQLite supplies them for its file-backed store; other dialects may leave
	// them unset until a native snapshot mechanism is available.
	BackupTo    func(context.Context, string) error
	RestoreFrom func(context.Context, string) error
	// Prepare is an optional provider-owned hook run once at the start of
	// Start, before anything touches the pools. It is where a provider does
	// setup that has to happen on a connection of its own and must not
	// happen at construction time: SQLite uses it to put a new database into
	// WAL mode, which materialises the file, and constructing a store is not
	// allowed to do that -- RestoreFrom runs against a constructed but
	// unstarted store and requires the destination not to exist.
	Prepare func(context.Context) error
	// Reset is an optional provider-owned hook clearing all data this store
	// owns, using the still-open pool (it must run before the store is
	// closed). See metadata.Resettable's doc comment for why this exists:
	// a live client/server backend's restore orchestration needs a way to
	// undo a brief resolve-and-start's real migrations against the actual
	// remote database, which a directory wipe (sqlite/badger's mechanism)
	// cannot touch. Left unset, Reset is a harmless no-op.
	Reset func(context.Context) error
	// ValidateBackup is an optional provider-owned hook checking a backup
	// file's structural integrity without touching any database -- see
	// metadata.BackupValidator's doc comment for why this exists
	// specifically for Resettable providers: their restore orchestration
	// resets a live remote target before RestoreFrom ever parses the
	// backup, so an invalid backup needs to be caught before that reset,
	// not after it. Left unset, ValidateBackup is a harmless no-op.
	ValidateBackup func(context.Context, string) error
}

Config contains backend-neutral dependencies for a Store.

type Dialect

type Dialect interface {
	Name() string
	Rebind(string) string
	QuoteIdentifier(string) string
	ParameterLimit() int
	BeginOptions(readOnly bool) *sql.TxOptions
	SetBulkMode(context.Context, Execer) error
	RestoreNormalMode(context.Context, Execer) error
	UpdatePlannerStats(context.Context, Execer) error
	DropIndexSQL(name, table string) string
	CreateIndexSQL(name, table string, columns []string) string
	CanDropIndex(name, table string) bool
}

Dialect is the deliberately small backend capability boundary. Metadata orchestration belongs in Store; only SQL mechanics and backend tuning belong behind this interface.

func MySQLDialect

func MySQLDialect() Dialect

MySQLDialect returns MySQL database/sql capabilities.

func PostgresDialect

func PostgresDialect() Dialect

PostgresDialect returns PostgreSQL database/sql capabilities.

func SQLiteDialect

func SQLiteDialect() Dialect

SQLiteDialect returns the capabilities used by the pure-Go SQLite driver.

type Execer

type Execer interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
}

Execer is implemented by *sql.DB, *sql.Conn, and *sql.Tx.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store owns the shared database/sql pools. Provider packages own DSN and driver selection; metadata behavior belongs here.

func New

func New(config Config) (*Store, error)

New constructs a shared store around already-opened connection pools.

func (*Store) AccountInactivityActivationMembership

func (s *Store) AccountInactivityActivationMembership(
	refs []models.StakeCredentialRef,
	txn types.Txn,
) (map[string]struct{}, error)

func (*Store) AccountLastWitnessSlots

func (s *Store) AccountLastWitnessSlots(
	refs []models.StakeCredentialRef,
	maxSlot uint64,
	txn types.Txn,
) (map[string]uint64, error)

func (*Store) AccountsWitnessedAfterSlot

func (s *Store) AccountsWitnessedAfterSlot(
	slot uint64,
	txn types.Txn,
) ([]models.StakeCredentialRef, error)

func (*Store) AddAccountRewardByCredential

func (s *Store) AddAccountRewardByCredential(
	credentialTag uint8,
	stakeKey []byte,
	amount uint64,
	slot uint64,
	sourceHash []byte,
	txn types.Txn,
) error

func (*Store) AddNetworkDonation

func (s *Store) AddNetworkDonation(
	slot, epoch, amount uint64,
	txn types.Txn,
) error

func (*Store) AddPostSnapshotAccountRewardByCredential

func (s *Store) AddPostSnapshotAccountRewardByCredential(
	credentialTag uint8,
	stakeKey []byte,
	amount uint64,
	slot uint64,
	sourceHash []byte,
	txn types.Txn,
) error

func (*Store) AddUtxos

func (s *Store) AddUtxos(
	utxos []models.UtxoSlot,
	txn types.Txn,
) error

func (*Store) ApplyAccountRewardWithdrawal

func (s *Store) ApplyAccountRewardWithdrawal(
	credentialTag uint8,
	stakeKey []byte,
	amount uint64,
	slot uint64,
	txHash []byte,
	txn types.Txn,
) error

func (*Store) BackupTo

func (s *Store) BackupTo(ctx context.Context, dstPath string) error

func (*Store) BuildCriticalDeferredIndexes

func (s *Store) BuildCriticalDeferredIndexes() error

BuildCriticalDeferredIndexes restores the indexes needed before API and rollback traffic begins. The recovery marker stays set until the full manifest is restored.

func (*Store) BuildDeferredIndexes

func (s *Store) BuildDeferredIndexes() error

BuildDeferredIndexes restores the full manifest and clears the durable recovery marker in the same transaction.

func (*Store) ClaimFallbackRewardSnapshot

func (s *Store) ClaimFallbackRewardSnapshot(
	snapshot *models.RewardSnapshot,
	txn types.Txn,
) (bool, error)

func (*Store) ClaimFallbackRewardSnapshotGuard

func (s *Store) ClaimFallbackRewardSnapshotGuard(
	epoch uint64,
	snapshotType string,
	txn types.Txn,
) (bool, uint, error)

func (*Store) ClearCommitteeQuorum

func (s *Store) ClearCommitteeQuorum(
	slot uint64,
	txn types.Txn,
) error

func (*Store) ClearDanglingDRepDelegations

func (s *Store) ClearDanglingDRepDelegations(
	atSlot uint64,
	txn types.Txn,
) (int, error)

func (*Store) ClearSyncState

func (s *Store) ClearSyncState(txn types.Txn) error

func (*Store) Close

func (s *Store) Close() error

Close closes each owned pool exactly once.

func (*Store) CloseContext

func (s *Store) CloseContext(ctx context.Context) error

CloseContext cancels maintenance and closes each owned pool. The lifecycle context is also passed to the maintenance wait so cancellation can interrupt a long-running VACUUM before the provider shutdown deadline expires.

func (*Store) CountAccountDelegationHistoryByCredential

func (s *Store) CountAccountDelegationHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountAccountRegistrationHistoryByCredential

func (s *Store) CountAccountRegistrationHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountAccountWithdrawalHistoryByCredential

func (s *Store) CountAccountWithdrawalHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountAddressTransactionsByCredential

func (s *Store) CountAddressTransactionsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	from *models.AddressTransactionPosition,
	to *models.AddressTransactionPosition,
	txn types.Txn,
) (int, error)

func (*Store) CountAddressesByCredential

func (s *Store) CountAddressesByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountPoolBlocksInSlotRange

func (s *Store) CountPoolBlocksInSlotRange(
	poolKeyHashes []lcommon.PoolKeyHash,
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) (map[string]uint64, uint64, error)

func (*Store) CountRewardAccountOutputsByCredential

func (s *Store) CountRewardAccountOutputsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountTransactionsByAddress

func (s *Store) CountTransactionsByAddress(
	paymentKey []byte,
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountTransactionsByMetadataLabel

func (s *Store) CountTransactionsByMetadataLabel(
	label uint64,
	txn types.Txn,
) (int, error)

func (*Store) CountTransactionsByPaymentCred

func (s *Store) CountTransactionsByPaymentCred(
	paymentKey []byte,
	txn types.Txn,
) (int, error)

func (*Store) CountTransactionsInSlotRange

func (s *Store) CountTransactionsInSlotRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) (int, error)

func (*Store) CreateAccount

func (s *Store) CreateAccount(
	txn types.Txn,
	account *models.Account,
) error

func (*Store) CreateDrep

func (s *Store) CreateDrep(txn types.Txn, drep *models.Drep) error

func (*Store) CreateMidnightAriadneRollback

func (s *Store) CreateMidnightAriadneRollback(
	txn types.Txn,
	rollback *models.MidnightAriadneRollback,
) error

func (*Store) CreateMidnightAssetCreate

func (s *Store) CreateMidnightAssetCreate(
	txn types.Txn,
	row *models.MidnightAssetCreate,
) error

func (*Store) CreateMidnightAssetSpend

func (s *Store) CreateMidnightAssetSpend(
	txn types.Txn,
	row *models.MidnightAssetSpend,
) error

func (*Store) CreateMidnightDeregistration

func (s *Store) CreateMidnightDeregistration(
	txn types.Txn,
	row *models.MidnightDeregistration,
) error

func (*Store) CreateMidnightRegistration

func (s *Store) CreateMidnightRegistration(
	txn types.Txn,
	row *models.MidnightRegistration,
) error

func (*Store) CreateUtxo

func (s *Store) CreateUtxo(txn types.Txn, utxo *models.Utxo) error

func (*Store) DeactivateAccounts

func (s *Store) DeactivateAccounts(
	txn types.Txn,
	refs []models.StakeCredentialRef,
) error

func (*Store) DeactivateDreps

func (s *Store) DeactivateDreps(
	txn types.Txn,
	credentials []models.StakeCredentialRef,
) error

func (*Store) DeleteAccountRewardsAfterSlot

func (s *Store) DeleteAccountRewardsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteAddressTransactionsAfterSlot

func (s *Store) DeleteAddressTransactionsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteBlockNoncesAfterPoint

func (s *Store) DeleteBlockNoncesAfterPoint(
	point ocommon.Point,
	txn types.Txn,
) error

func (*Store) DeleteBlockNoncesBeforeSlot

func (s *Store) DeleteBlockNoncesBeforeSlot(
	slotNumber uint64,
	txn types.Txn,
) error

func (*Store) DeleteBlockNoncesBeforeSlotWithoutCheckpoints

func (s *Store) DeleteBlockNoncesBeforeSlotWithoutCheckpoints(
	slotNumber uint64,
	txn types.Txn,
) error

func (*Store) DeleteCertificatesAfterSlot

func (s *Store) DeleteCertificatesAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteCommitteeMembersAfterSlot

func (s *Store) DeleteCommitteeMembersAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteConstitutionsAfterSlot

func (s *Store) DeleteConstitutionsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteEpochSummariesAfterEpoch

func (s *Store) DeleteEpochSummariesAfterEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeleteEpochsAfterSlot

func (s *Store) DeleteEpochsAfterSlot(slot uint64, txn types.Txn) error

func (*Store) DeleteGovernanceProposalsAfterSlot

func (s *Store) DeleteGovernanceProposalsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteGovernanceVotesAfterSlot

func (s *Store) DeleteGovernanceVotesAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteMidnightAriadneParamsByEpoch

func (s *Store) DeleteMidnightAriadneParamsByEpoch(
	txn types.Txn,
	epoch uint64,
) error

func (*Store) DeleteMidnightAriadneRollbacksBeforeBlock

func (s *Store) DeleteMidnightAriadneRollbacksBeforeBlock(
	txn types.Txn,
	blockNumber uint64,
) error

func (*Store) DeleteMidnightAriadneRollbacksByBlock

func (s *Store) DeleteMidnightAriadneRollbacksByBlock(
	txn types.Txn,
	blockNumber uint64,
) error

func (*Store) DeleteMidnightAssetCreatesByBlock

func (s *Store) DeleteMidnightAssetCreatesByBlock(
	txn types.Txn,
	blockNumber uint64,
) ([]models.MidnightAssetCreate, error)

func (*Store) DeleteMidnightAssetSpendsByBlock

func (s *Store) DeleteMidnightAssetSpendsByBlock(
	txn types.Txn,
	blockNumber uint64,
) ([]models.MidnightAssetSpend, error)

func (*Store) DeleteMidnightCommitteeCandidateRegistrationsByBlock

func (s *Store) DeleteMidnightCommitteeCandidateRegistrationsByBlock(
	txn types.Txn,
	blockNumber uint64,
) error

func (*Store) DeleteMidnightDeregistrationsByBlock

func (s *Store) DeleteMidnightDeregistrationsByBlock(
	txn types.Txn,
	blockNumber uint64,
) ([]models.MidnightDeregistration, error)

func (*Store) DeleteMidnightEpochCandidatesByBlock

func (s *Store) DeleteMidnightEpochCandidatesByBlock(
	txn types.Txn,
	blockNumber uint64,
) error

func (*Store) DeleteMidnightGovernanceDatumsByBlock

func (s *Store) DeleteMidnightGovernanceDatumsByBlock(
	txn types.Txn,
	blockNumber uint64,
) error

func (*Store) DeleteMidnightRegistrationsByBlock

func (s *Store) DeleteMidnightRegistrationsByBlock(
	txn types.Txn,
	blockNumber uint64,
) ([]models.MidnightRegistration, error)

func (*Store) DeleteNetworkDonationsAfterSlot

func (s *Store) DeleteNetworkDonationsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteNetworkStateAfterSlot

func (s *Store) DeleteNetworkStateAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeletePParamUpdatesAfterSlot

func (s *Store) DeletePParamUpdatesAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeletePParamsAfterSlot

func (s *Store) DeletePParamsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeletePoolStakeSnapshotsAfterEpoch

func (s *Store) DeletePoolStakeSnapshotsAfterEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeletePoolStakeSnapshotsBeforeEpoch

func (s *Store) DeletePoolStakeSnapshotsBeforeEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeletePoolStakeSnapshotsForEpoch

func (s *Store) DeletePoolStakeSnapshotsForEpoch(
	epoch uint64,
	snapshotType string,
	txn types.Txn,
) error

func (*Store) DeleteRewardInputsForEpoch

func (s *Store) DeleteRewardInputsForEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeleteRewardOutputsForEpoch

func (s *Store) DeleteRewardOutputsForEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeleteRewardStakeInputBeforeEpoch

func (s *Store) DeleteRewardStakeInputBeforeEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeleteRewardStateAfterSlot

func (s *Store) DeleteRewardStateAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteRewardStateBeforeEpoch

func (s *Store) DeleteRewardStateBeforeEpoch(
	epoch uint64,
	txn types.Txn,
) error

func (*Store) DeleteSyncState

func (s *Store) DeleteSyncState(key string, txn types.Txn) error

func (*Store) DeleteTransactionMetadataLabelsAfterSlot

func (s *Store) DeleteTransactionMetadataLabelsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteTransactionsAfterSlot

func (s *Store) DeleteTransactionsAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DeleteUtxo

func (s *Store) DeleteUtxo(
	utxoID models.UtxoId,
	txn types.Txn,
) error

func (*Store) DeleteUtxos

func (s *Store) DeleteUtxos(
	utxoIDs []models.UtxoId,
	txn types.Txn,
) error

func (*Store) DeleteUtxosAfterSlot

func (s *Store) DeleteUtxosAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) DiskSize

func (s *Store) DiskSize() (int64, error)

DiskSize returns backend storage usage when the provider supplies it.

func (*Store) DropDeferredIndexes

func (s *Store) DropDeferredIndexes() error

DropDeferredIndexes records the durable recovery marker and drops the manifest in one SQLite transaction.

func (*Store) EnsureOffchainMetadataPointers

func (s *Store) EnsureOffchainMetadataPointers(
	ctx context.Context,
	now time.Time,
	txn types.Txn,
) (int, error)

func (*Store) FindMidnightAriadneRollbacksByBlock

func (s *Store) FindMidnightAriadneRollbacksByBlock(
	txn types.Txn,
	blockNumber uint64,
) ([]models.MidnightAriadneRollback, error)

func (*Store) FindMidnightAssetCreatesFrom

func (s *Store) FindMidnightAssetCreatesFrom(
	startBlock uint64,
	startTxIndex uint32,
	limit int,
	txn types.Txn,
) ([]models.MidnightAssetCreate, error)

func (*Store) FindMidnightAssetSpendsFrom

func (s *Store) FindMidnightAssetSpendsFrom(
	startBlock uint64,
	startTxIndex uint32,
	limit int,
	txn types.Txn,
) ([]models.MidnightAssetSpend, error)

func (*Store) FindMidnightDeregistrationsFrom

func (s *Store) FindMidnightDeregistrationsFrom(
	startBlock uint64,
	startTxIndex uint32,
	limit int,
	txn types.Txn,
) ([]models.MidnightDeregistration, error)

func (*Store) FindMidnightRegistrationsFrom

func (s *Store) FindMidnightRegistrationsFrom(
	startBlock uint64,
	startTxIndex uint32,
	limit int,
	txn types.Txn,
) ([]models.MidnightRegistration, error)

func (*Store) FindUnspentMidnightAssetCreates

func (s *Store) FindUnspentMidnightAssetCreates() (
	[]models.MidnightAssetCreate,
	error,
)

func (*Store) FindUnspentMidnightRegistrations

func (s *Store) FindUnspentMidnightRegistrations() (
	[]models.MidnightRegistration,
	error,
)

func (*Store) FlushBatch

func (s *Store) FlushBatch(
	accumulator types.MetadataBatchAccumulator,
	_ types.Txn,
) error

func (*Store) GetAccountByCredential

func (s *Store) GetAccountByCredential(
	credentialTag uint8,
	stakeKey []byte,
	includeInactive bool,
	txn types.Txn,
) (*models.Account, error)

func (*Store) GetAccountDelegationHistoryByCredential

func (s *Store) GetAccountDelegationHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]models.AccountDelegationHistoryRow, error)

func (*Store) GetAccountRegistrationHistoryByCredential

func (s *Store) GetAccountRegistrationHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]models.AccountRegistrationHistoryRow, error)

func (*Store) GetAccountSumsByCredential

func (s *Store) GetAccountSumsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (models.AccountSums, error)

func (*Store) GetAccountWithdrawalHistoryByCredential

func (s *Store) GetAccountWithdrawalHistoryByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]models.AccountWithdrawalHistoryRow, error)

func (*Store) GetAccountsActiveAtSlot

func (s *Store) GetAccountsActiveAtSlot(
	refs []models.StakeCredentialRef,
	slot uint64,
	txn types.Txn,
) (map[string]struct{}, error)

func (*Store) GetAccountsByCredential

func (s *Store) GetAccountsByCredential(
	refs []models.StakeCredentialRef,
	includeInactive bool,
	txn types.Txn,
) (map[string]*models.Account, error)

func (*Store) GetActiveAccountCredentials

func (s *Store) GetActiveAccountCredentials(
	txn types.Txn,
) ([]models.StakeCredentialRef, error)

func (*Store) GetActiveCommitteeMembers

func (s *Store) GetActiveCommitteeMembers(
	txn types.Txn,
) ([]*models.AuthCommitteeHot, error)

func (*Store) GetActiveDreps

func (s *Store) GetActiveDreps(
	txn types.Txn,
) ([]*models.Drep, error)

func (*Store) GetActiveGovernanceProposals

func (s *Store) GetActiveGovernanceProposals(
	epoch uint64,
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetActivePoolKeyHashes

func (s *Store) GetActivePoolKeyHashes(
	txn types.Txn,
) ([][]byte, error)

func (*Store) GetActivePoolKeyHashesAtSlot

func (s *Store) GetActivePoolKeyHashesAtSlot(
	slot uint64,
	txn types.Txn,
) ([][]byte, error)

func (*Store) GetActivePoolKeyHashesOrdered

func (s *Store) GetActivePoolKeyHashesOrdered(
	txn types.Txn,
) ([][]byte, error)

func (*Store) GetActivePoolRelays

func (s *Store) GetActivePoolRelays(
	txn types.Txn,
) ([]models.PoolRegistrationRelay, error)

GetActivePoolRelays returns relays from each active pool's latest registration. The query uses the same chain-position ordering as active-pool selection and avoids loading historical registrations into memory.

func (*Store) GetAddressTransactionsByCredential

func (s *Store) GetAddressTransactionsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	from *models.AddressTransactionPosition,
	to *models.AddressTransactionPosition,
	txn types.Txn,
) ([]models.AccountTransactionAssociationRow, error)

func (*Store) GetAddressesByCredential

func (s *Store) GetAddressesByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]models.AddressTransaction, error)

func (*Store) GetAssetByPolicyAndName

func (s *Store) GetAssetByPolicyAndName(
	policyID lcommon.Blake2b224,
	assetName []byte,
	txn types.Txn,
) (models.Asset, error)

func (*Store) GetAssetMintBurnInfo

func (s *Store) GetAssetMintBurnInfo(
	policyID lcommon.Blake2b224,
	assetName []byte,
	txn types.Txn,
) ([]byte, int, error)

func (*Store) GetAssetQuantityByPolicyAndName

func (s *Store) GetAssetQuantityByPolicyAndName(
	policyID lcommon.Blake2b224,
	assetName []byte,
	txn types.Txn,
) (uint64, error)

func (*Store) GetBackfillCheckpoint

func (s *Store) GetBackfillCheckpoint(
	phase string,
	txn types.Txn,
) (*models.BackfillCheckpoint, error)

func (*Store) GetBlockNonce

func (s *Store) GetBlockNonce(
	point ocommon.Point,
	txn types.Txn,
) ([]byte, error)

func (*Store) GetBlockNoncesInSlotRange

func (s *Store) GetBlockNoncesInSlotRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) ([]models.BlockNonce, error)

func (*Store) GetBlockSlotRangeStats

func (s *Store) GetBlockSlotRangeStats(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) (metadata.SlotRangeStats, error)

func (*Store) GetChildGovernanceProposals

func (s *Store) GetChildGovernanceProposals(
	parentTxHash []byte,
	parentActionIndex uint32,
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetCommitTimestamp

func (s *Store) GetCommitTimestamp() (int64, error)

func (*Store) GetCommitteeActiveCount

func (s *Store) GetCommitteeActiveCount(
	txn types.Txn,
) (int, error)

func (*Store) GetCommitteeMember

func (s *Store) GetCommitteeMember(
	coldKey []byte,
	txn types.Txn,
) (*models.AuthCommitteeHot, error)

func (*Store) GetCommitteeMembers

func (s *Store) GetCommitteeMembers(
	txn types.Txn,
) ([]*models.CommitteeMember, error)

func (*Store) GetCommitteeMembersIncludeDeleted

func (s *Store) GetCommitteeMembersIncludeDeleted(
	txn types.Txn,
) ([]*models.CommitteeMember, error)

func (*Store) GetCommitteeQuorum

func (s *Store) GetCommitteeQuorum(
	txn types.Txn,
) (*types.Rat, error)

func (*Store) GetConstitution

func (s *Store) GetConstitution(
	txn types.Txn,
) (*models.Constitution, error)

func (*Store) GetControlledAmountByCredential

func (s *Store) GetControlledAmountByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) (uint64, error)

func (*Store) GetDRepDelegators

func (s *Store) GetDRepDelegators(
	credentialTag uint8,
	credential []byte,
	txn types.Txn,
) ([]models.StakeCredentialRef, error)

func (*Store) GetDRepVotingPower

func (s *Store) GetDRepVotingPower(
	credentialTag uint8,
	credential []byte,
	expiryEpoch uint64,
	txn types.Txn,
) (uint64, error)

func (*Store) GetDRepVotingPowerBatch

func (s *Store) GetDRepVotingPowerBatch(
	credentials []models.StakeCredentialRef,
	expiryEpoch uint64,
	txn types.Txn,
) (map[string]uint64, error)

func (*Store) GetDRepVotingPowerByType

func (s *Store) GetDRepVotingPowerByType(
	drepTypes []uint64,
	expiryEpoch uint64,
	txn types.Txn,
) (map[uint64]uint64, error)

func (*Store) GetDatum

func (s *Store) GetDatum(
	hash lcommon.Blake2b256,
	txn types.Txn,
) (*models.Datum, error)

func (*Store) GetDrep

func (s *Store) GetDrep(
	credential []byte,
	includeInactive bool,
	txn types.Txn,
) (*models.Drep, error)

func (*Store) GetDrepByCredential

func (s *Store) GetDrepByCredential(
	credentialTag uint8,
	credential []byte,
	includeInactive bool,
	txn types.Txn,
) (*models.Drep, error)

func (*Store) GetDrepLastRegistrationSlot

func (s *Store) GetDrepLastRegistrationSlot(
	credentialTag uint8,
	credential []byte,
	txn types.Txn,
) (uint64, error)

func (*Store) GetDreps

func (s *Store) GetDreps(
	txn types.Txn,
) ([]models.DrepListRow, error)

func (*Store) GetEnactedGovernanceProposalsAt

func (s *Store) GetEnactedGovernanceProposalsAt(
	epoch uint64,
	slot uint64,
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetEpoch

func (s *Store) GetEpoch(
	epochID uint64,
	txn types.Txn,
) (*models.Epoch, error)

func (*Store) GetEpochBoundaryRewardStakeInputsForPools

func (s *Store) GetEpochBoundaryRewardStakeInputsForPools(
	poolKeyHashes [][]byte,
	snapshotSlot uint64,
	boundarySlot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) ([]*models.RewardStakeInput, error)

func (*Store) GetEpochBoundaryStakeByPools

func (s *Store) GetEpochBoundaryStakeByPools(
	poolKeyHashes [][]byte,
	snapshotSlot uint64,
	boundarySlot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) (map[string]uint64, map[string]uint64, error)

func (*Store) GetEpochBySlot

func (s *Store) GetEpochBySlot(
	slot uint64,
	txn types.Txn,
) (*models.Epoch, error)

func (*Store) GetEpochSummary

func (s *Store) GetEpochSummary(
	epoch uint64,
	txn types.Txn,
) (*models.EpochSummary, error)

func (*Store) GetEpochs

func (s *Store) GetEpochs(txn types.Txn) ([]models.Epoch, error)

func (*Store) GetEpochsByEra

func (s *Store) GetEpochsByEra(
	eraID uint,
	txn types.Txn,
) ([]models.Epoch, error)

func (*Store) GetExpiredDReps

func (s *Store) GetExpiredDReps(
	epoch uint64,
	txn types.Txn,
) ([]*models.Drep, error)

func (*Store) GetExpiredGovernanceProposalsAt

func (s *Store) GetExpiredGovernanceProposalsAt(
	epoch uint64,
	slot uint64,
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetExpiringGovernanceProposals

func (s *Store) GetExpiringGovernanceProposals(
	epoch uint64,
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetGenesisDelegationForSlot

func (s *Store) GetGenesisDelegationForSlot(
	genesisHash []byte,
	blockSlot uint64,
	txn types.Txn,
) (*models.GenesisDelegation, error)

func (*Store) GetGovernanceProposal

func (s *Store) GetGovernanceProposal(
	txHash []byte,
	actionIndex uint32,
	txn types.Txn,
) (*models.GovernanceProposal, error)

func (*Store) GetGovernanceVotes

func (s *Store) GetGovernanceVotes(
	proposalID uint,
	txn types.Txn,
) ([]*models.GovernanceVote, error)

func (*Store) GetImportCheckpoint

func (s *Store) GetImportCheckpoint(
	importKey string,
	txn types.Txn,
) (*models.ImportCheckpoint, error)

func (*Store) GetLastBlockNonceInRange

func (s *Store) GetLastBlockNonceInRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) ([]byte, error)

func (*Store) GetLastEnactedGovernanceProposal

func (s *Store) GetLastEnactedGovernanceProposal(
	actionTypes []uint8,
	txn types.Txn,
) (*models.GovernanceProposal, error)

func (*Store) GetLatestBlockNonce

func (s *Store) GetLatestBlockNonce(
	txn types.Txn,
) (models.BlockNonce, bool, error)

GetLatestBlockNonce returns the highest-slot nonce row. The nonce is written in the same metadata transaction as the corresponding ledger effects, so this row is the durable ledger-state high-water mark.

func (*Store) GetLatestEpochSummary

func (s *Store) GetLatestEpochSummary(
	txn types.Txn,
) (*models.EpochSummary, error)

func (*Store) GetLatestMidnightAriadneParams

func (s *Store) GetLatestMidnightAriadneParams(
	txn types.Txn,
) (*models.MidnightAriadneParams, error)

func (*Store) GetLatestMidnightGovernanceDatum

func (s *Store) GetLatestMidnightGovernanceDatum(
	datumType string,
	blockNumber uint64,
	txn types.Txn,
) (*models.MidnightGovernanceDatum, error)

func (*Store) GetLiveStakeInputsForPools

func (s *Store) GetLiveStakeInputsForPools(
	poolKeyHashes [][]byte,
	expiryEpoch uint64,
	txn types.Txn,
) ([]*models.RewardStakeInput, error)

func (*Store) GetLiveUtxosBySlot

func (s *Store) GetLiveUtxosBySlot(
	slot uint64,
	txn types.Txn,
) ([]models.UtxoId, error)

func (*Store) GetMIRCertsInSlotRange

func (s *Store) GetMIRCertsInSlotRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) ([]models.MIREffect, error)

func (*Store) GetMidnightAriadneParamsAtOrBeforeEpoch

func (s *Store) GetMidnightAriadneParamsAtOrBeforeEpoch(
	epoch uint64,
	txn types.Txn,
) (*models.MidnightAriadneParams, error)

func (*Store) GetMidnightAriadneParamsByEpoch

func (s *Store) GetMidnightAriadneParamsByEpoch(
	epoch uint64,
	txn types.Txn,
) (*models.MidnightAriadneParams, error)

func (*Store) GetMidnightCandidates

func (s *Store) GetMidnightCandidates(
	address ledger.Address,
	txn types.Txn,
) ([]models.Utxo, error)

func (*Store) GetMidnightCommitteeCandidateRegistrationsByTxHashes

func (s *Store) GetMidnightCommitteeCandidateRegistrationsByTxHashes(
	txHashes [][]byte,
	txn types.Txn,
) ([]models.MidnightCommitteeCandidateRegistration, error)

func (*Store) GetMidnightEpochCandidatesByEpoch

func (s *Store) GetMidnightEpochCandidatesByEpoch(
	epoch uint64,
	txn types.Txn,
) (*models.MidnightEpochCandidates, error)

func (*Store) GetNetworkState

func (s *Store) GetNetworkState(
	txn types.Txn,
) (*models.NetworkState, error)

func (*Store) GetNodeSettings

func (s *Store) GetNodeSettings() (*types.NodeSettings, error)

func (*Store) GetNodeSettingsGates

func (s *Store) GetNodeSettingsGates() (nodesettings.Values, error)

GetNodeSettingsGates returns the persisted node settings gate values, keyed by gate name. An empty result means no gates have been recorded yet.

func (*Store) GetOffchainMetadata

func (s *Store) GetOffchainMetadata(
	sourceType string,
	url string,
	hash []byte,
	txn types.Txn,
) (*models.OffchainMetadata, error)

func (*Store) GetOffchainMetadataBatch

func (s *Store) GetOffchainMetadataBatch(
	sourceType string,
	urls []string,
	txn types.Txn,
) ([]models.OffchainMetadata, error)

func (*Store) GetOffchainMetadataFetchBatch

func (s *Store) GetOffchainMetadataFetchBatch(
	ctx context.Context,
	limit int,
	now time.Time,
	txn types.Txn,
) ([]models.OffchainMetadata, error)

func (*Store) GetPParamUpdates

func (s *Store) GetPParamUpdates(
	epoch uint64,
	txn types.Txn,
) ([]models.PParamUpdate, error)

func (*Store) GetPParams

func (s *Store) GetPParams(
	epoch uint64,
	eraID uint,
	txn types.Txn,
) ([]models.PParams, error)

func (*Store) GetPool

func (s *Store) GetPool(
	poolKeyHash lcommon.PoolKeyHash,
	includeInactive bool,
	txn types.Txn,
) (*models.Pool, error)

func (*Store) GetPoolBlockIssuersInSlotRange

func (s *Store) GetPoolBlockIssuersInSlotRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) ([]models.PoolOpCertSequence, error)

func (*Store) GetPoolByVrfKeyHash

func (s *Store) GetPoolByVrfKeyHash(
	vrfKeyHash []byte,
	txn types.Txn,
) (*models.Pool, error)

func (*Store) GetPoolCertificateHistory

func (s *Store) GetPoolCertificateHistory(
	pkh lcommon.PoolKeyHash,
	txn types.Txn,
) ([][]byte, [][]byte, error)

func (*Store) GetPoolOwnerStakeAtSlot

func (s *Store) GetPoolOwnerStakeAtSlot(
	ownerKeys [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) (map[string]uint64, error)

func (*Store) GetPoolRegistrations

func (s *Store) GetPoolRegistrations(
	poolKeyHash lcommon.PoolKeyHash,
	txn types.Txn,
) ([]lcommon.PoolRegistrationCertificate, error)

GetPoolRegistrations reconstructs the ledger certificates for a pool.

func (*Store) GetPoolRegistrationsAtSlot

func (s *Store) GetPoolRegistrationsAtSlot(
	poolKeyHashes []lcommon.PoolKeyHash,
	slot uint64,
	txn types.Txn,
) ([]models.PoolRegistration, error)

GetPoolRegistrationsAtSlot returns the latest registration for every requested pool at or before slot. Certificate position breaks same-slot ties, with the row ID as a deterministic final fallback.

func (*Store) GetPoolRegistrationsEffectiveForEpoch

func (s *Store) GetPoolRegistrationsEffectiveForEpoch(
	poolKeyHashes []lcommon.PoolKeyHash,
	epochStartSlot uint64,
	endedEpoch uint64,
	snapshotSlot uint64,
	txn types.Txn,
) ([]models.PoolRegistration, error)

func (*Store) GetPoolStakeSnapshot

func (s *Store) GetPoolStakeSnapshot(
	epoch uint64,
	snapshotType string,
	poolKeyHash []byte,
	txn types.Txn,
) (*models.PoolStakeSnapshot, error)

func (*Store) GetPoolStakeSnapshotsByEpoch

func (s *Store) GetPoolStakeSnapshotsByEpoch(
	epoch uint64,
	snapshotType string,
	txn types.Txn,
) ([]*models.PoolStakeSnapshot, error)

func (*Store) GetPoolStakeSnapshotsForPools

func (s *Store) GetPoolStakeSnapshotsForPools(
	epoch uint64,
	snapshotType string,
	poolKeyHashes [][]byte,
	txn types.Txn,
) ([]*models.PoolStakeSnapshot, error)

GetPoolStakeSnapshotsForPools returns the snapshot rows for just the pools named, for a caller that wants a bounded subset rather than a whole epoch.

A named pool with no row is simply absent from the result: the snapshot holds a row per pool with stake, so a pool it does not hold has no stake in that snapshot rather than a stake of zero.

The read is chunked over the dialect's parameter limit rather than issued per pool, so a large filter costs a bounded number of round trips instead of one per pool named.

func (*Store) GetPools

func (s *Store) GetPools(
	poolKeyHashes []lcommon.PoolKeyHash,
	txn types.Txn,
) ([]models.Pool, error)

func (*Store) GetPoolsRetiringAtEpoch

func (s *Store) GetPoolsRetiringAtEpoch(
	epoch uint64,
	boundarySlot uint64,
	txn types.Txn,
) ([]models.PoolRetirementRefund, error)

func (*Store) GetPredefinedDrepFirstSeenSlots

func (s *Store) GetPredefinedDrepFirstSeenSlots(
	txn types.Txn,
) (map[uint64]uint64, error)

func (*Store) GetRatifiedGovernanceProposals

func (s *Store) GetRatifiedGovernanceProposals(
	txn types.Txn,
) ([]*models.GovernanceProposal, error)

func (*Store) GetResignedCommitteeMembers

func (s *Store) GetResignedCommitteeMembers(
	coldKeys [][]byte,
	txn types.Txn,
) (map[string]bool, error)

func (*Store) GetRetiringPools

func (s *Store) GetRetiringPools(
	currentEpoch uint64,
	txn types.Txn,
) ([]models.PoolRetiringRow, error)

func (*Store) GetRewardAccountOutputs

func (s *Store) GetRewardAccountOutputs(
	epoch uint64,
	txn types.Txn,
) ([]*models.RewardAccountOutput, error)

func (*Store) GetRewardAccountOutputsByCredential

func (s *Store) GetRewardAccountOutputsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]*models.RewardAccountOutput, error)

func (*Store) GetRewardAdaPots

func (s *Store) GetRewardAdaPots(
	epoch uint64,
	txn types.Txn,
) (*models.RewardAdaPots, error)

func (*Store) GetRewardPoolInputs

func (s *Store) GetRewardPoolInputs(
	epoch uint64,
	txn types.Txn,
) ([]*models.RewardPoolInput, error)

func (*Store) GetRewardPoolOutputs

func (s *Store) GetRewardPoolOutputs(
	epoch uint64,
	txn types.Txn,
) ([]*models.RewardPoolOutput, error)

func (*Store) GetRewardSnapshot

func (s *Store) GetRewardSnapshot(
	epoch uint64,
	snapshotType string,
	txn types.Txn,
) (*models.RewardSnapshot, error)

func (*Store) GetRewardStakeInputs

func (s *Store) GetRewardStakeInputs(
	epoch uint64,
	txn types.Txn,
) ([]*models.RewardStakeInput, error)

func (*Store) GetRewardStakeInputsForPools

func (s *Store) GetRewardStakeInputsForPools(
	poolKeyHashes [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) ([]*models.RewardStakeInput, error)

func (*Store) GetScript

func (s *Store) GetScript(
	hash lcommon.ScriptHash,
	txn types.Txn,
) (*models.Script, error)

func (*Store) GetScriptLockedSupply

func (s *Store) GetScriptLockedSupply(txn types.Txn) (uint64, error)

func (*Store) GetStakeByPool

func (s *Store) GetStakeByPool(
	poolKeyHash []byte,
	txn types.Txn,
) (uint64, uint64, error)

func (*Store) GetStakeByPools

func (s *Store) GetStakeByPools(
	poolKeyHashes [][]byte,
	txn types.Txn,
) (map[string]uint64, map[string]uint64, error)

func (*Store) GetStakeByPoolsAtSlot

func (s *Store) GetStakeByPoolsAtSlot(
	poolKeyHashes [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) (map[string]uint64, map[string]uint64, error)

func (*Store) GetStakeRegistrationsByCredential

func (s *Store) GetStakeRegistrationsByCredential(
	credentialTag uint8,
	stakingKey []byte,
	txn types.Txn,
) ([]lcommon.StakeRegistrationCertificate, error)

func (*Store) GetSyncState

func (s *Store) GetSyncState(key string, txn types.Txn) (string, error)

func (*Store) GetTip

func (s *Store) GetTip(txn types.Txn) (ochainsync.Tip, error)

func (*Store) GetTotalActiveStake

func (s *Store) GetTotalActiveStake(
	epoch uint64,
	snapshotType string,
	txn types.Txn,
) (uint64, error)

func (*Store) GetTransactionByHash

func (s *Store) GetTransactionByHash(
	hash []byte,
	txn types.Txn,
) (*models.Transaction, error)

func (*Store) GetTransactionHashesAfterSlot

func (s *Store) GetTransactionHashesAfterSlot(
	slot uint64,
	txn types.Txn,
) ([][]byte, error)

func (*Store) GetTransactionIDByHash

func (s *Store) GetTransactionIDByHash(
	hash []byte,
	txn types.Txn,
) (uint, bool, error)

func (*Store) GetTransactionMetadataByHash

func (s *Store) GetTransactionMetadataByHash(
	hash []byte,
	txn types.Txn,
) ([]byte, error)

func (*Store) GetTransactionSlotByHash

func (s *Store) GetTransactionSlotByHash(
	hash []byte,
	txn types.Txn,
) (uint64, bool, error)

func (*Store) GetTransactionsByAddress

func (s *Store) GetTransactionsByAddress(
	paymentKey []byte,
	credentialTag uint8,
	stakingKey []byte,
	limit int,
	offset int,
	order string,
	txn types.Txn,
) ([]models.Transaction, error)

func (*Store) GetTransactionsByBlockHash

func (s *Store) GetTransactionsByBlockHash(
	blockHash []byte,
	txn types.Txn,
) ([]models.Transaction, error)

func (*Store) GetTransactionsByHashes

func (s *Store) GetTransactionsByHashes(
	hashes [][]byte,
	txn types.Txn,
) ([]models.Transaction, error)

func (*Store) GetTransactionsByMetadataLabel

func (s *Store) GetTransactionsByMetadataLabel(
	label uint64,
	limit int,
	offset int,
	descending bool,
	txn types.Txn,
) ([]models.Transaction, error)

func (*Store) GetUtxo

func (s *Store) GetUtxo(
	txID []byte,
	index uint32,
	txn types.Txn,
) (*models.Utxo, error)

func (*Store) GetUtxoBalanceByAddress

func (s *Store) GetUtxoBalanceByAddress(
	address lcommon.Address,
	mode models.UtxoAddressMatchMode,
	txn types.Txn,
) (models.AddressBalance, error)

func (*Store) GetUtxoIncludingSpent

func (s *Store) GetUtxoIncludingSpent(
	txID []byte,
	index uint32,
	txn types.Txn,
) (*models.Utxo, error)

func (*Store) GetUtxoPaymentScriptByCredential

func (s *Store) GetUtxoPaymentScriptByCredential(
	credentialTag uint8,
	stakingKey []byte,
	paymentKeys [][]byte,
	txn types.Txn,
) (map[string]bool, error)

func (*Store) GetUtxosAddedAfterSlot

func (s *Store) GetUtxosAddedAfterSlot(
	slot uint64,
	txn types.Txn,
) ([]models.Utxo, error)

func (*Store) GetUtxosByAddress

func (s *Store) GetUtxosByAddress(
	patterns []models.UtxoAddressPattern,
	txn types.Txn,
) ([]models.Utxo, error)

GetUtxosByAddress runs one OR-joined query per chunk of patterns -- a single statement covering every pattern can exceed the dialect's bound-parameter limit (e.g. SQLite's 999) or its OR-expression tree depth limit once enough addresses are requested. Chunking is bounded by both accumulated bind-argument count and branch count: a pattern whose exact-address hash decodes as the zero hash for both payment and staking (e.g. a Byron address with an all-zero payment hash) falls back to a zero-argument branch in AppendUtxoAddressPatternOrBranch, so argument-count alone would never chunk a run of such patterns before the expression tree overflowed. Candidates are deduplicated by (tx id, output index) across chunks -- a coarse, non-selective branch (e.g. the zero-argument fallback above) can return the same candidate rows from every chunk it appears in -- before assets are loaded once on the final deduplicated set, so asset-loading cost is bounded by the result size rather than chunk count times candidate-set size.

func (*Store) GetUtxosByAddressAtSlot

func (s *Store) GetUtxosByAddressAtSlot(
	pattern models.UtxoAddressPattern,
	slot uint64,
	txn types.Txn,
) ([]models.Utxo, error)

func (*Store) GetUtxosByAddressWithOrdering

func (s *Store) GetUtxosByAddressWithOrdering(
	query *models.UtxoWithOrderingQuery,
	txn types.Txn,
) ([]models.UtxoWithOrdering, error)

func (*Store) GetUtxosByAssets

func (s *Store) GetUtxosByAssets(
	policyID []byte,
	assetName []byte,
	txn types.Txn,
) ([]models.Utxo, error)

func (*Store) GetUtxosByRefs added in v0.70.0

func (s *Store) GetUtxosByRefs(
	refs []models.UtxoId,
	txn types.Txn,
) ([]models.Utxo, error)

GetUtxosByRefs retrieves multiple live UTxOs by their (tx_id, output_idx) references in a single batch. Refs with no matching live UTxO are simply absent from the result. A ref repeated in the input yields at most one row, keeping one-row-per-requested-ref semantics for callers.

func (*Store) GetUtxosBySlot

func (s *Store) GetUtxosBySlot(
	slot uint64,
	txn types.Txn,
) ([]models.UtxoId, error)

func (*Store) GetUtxosDeletedBeforeSlot

func (s *Store) GetUtxosDeletedBeforeSlot(
	slot uint64,
	limit int,
	txn types.Txn,
) ([]models.Utxo, error)

func (*Store) HasDeferredIndexesPending

func (s *Store) HasDeferredIndexesPending() (bool, error)

HasDeferredIndexesPending reports whether a prior drop/rebuild cycle still owns the durable recovery marker.

func (*Store) HasDestructiveReset added in v0.70.0

func (s *Store) HasDestructiveReset() bool

HasDestructiveReset reports whether Reset actually mutates a live target (postgres/mysql, which wire a real Config.Reset callback) rather than being a harmless no-op (sqlite, which never sets one). Every backend's concrete *Store satisfies metadata.Resettable's Reset(ctx) error method regardless, so a plain type assertion against that interface alone cannot distinguish "genuinely destructive" from "no-op" -- callers that need to know whether Reset already happening (or having failed partway) means there is no safe pre-restore state left to resume on (see node_lifecycle.go's Restore) must check this instead.

func (*Store) ImportAccount

func (s *Store) ImportAccount(
	account *models.Account,
	txn types.Txn,
) error

func (*Store) ImportDrep

func (s *Store) ImportDrep(
	drep *models.Drep,
	registration *models.RegistrationDrep,
	txn types.Txn,
) error

func (*Store) ImportPool

func (s *Store) ImportPool(
	pool *models.Pool,
	registration *models.PoolRegistration,
	txn types.Txn,
) error

func (*Store) ImportUtxos

func (s *Store) ImportUtxos(
	utxos []models.Utxo,
	txn types.Txn,
) error

func (*Store) InsertDrepIfAbsent

func (s *Store) InsertDrepIfAbsent(
	credentialTag uint8,
	credential []byte,
	slot uint64,
	url string,
	hash []byte,
	active bool,
	txn types.Txn,
) error

func (*Store) InsertMidnightCommitteeCandidateRegistration

func (s *Store) InsertMidnightCommitteeCandidateRegistration(
	txn types.Txn,
	row *models.MidnightCommitteeCandidateRegistration,
) error

func (*Store) InsertMidnightGovernanceDatum

func (s *Store) InsertMidnightGovernanceDatum(
	txn types.Txn,
	datum *models.MidnightGovernanceDatum,
) error

func (*Store) InsertNodeSettingsGateIfAbsent

func (s *Store) InsertNodeSettingsGateIfAbsent(
	name string,
	value string,
	recordedEpoch uint64,
	recordedSlot uint64,
) (bool, error)

InsertNodeSettingsGateIfAbsent persists a single gate only if no row for name exists yet, reporting whether this call is what created it. Unlike SetNodeSettingsGates's unconditional upsert, this lets a caller detect a concurrent opener's first-ever write to the same gate (see commit_timestamp.go's evaluateAndPersistGates) instead of silently overwriting it -- the loser learns it lost and can re-evaluate against what is now actually persisted rather than assuming its own write landed.

func (*Store) InsertNodeSettingsGatesIfAbsent

func (s *Store) InsertNodeSettingsGatesIfAbsent(
	gates nodesettings.Values,
	recordedEpoch uint64,
	recordedSlot uint64,
) (bool, error)

InsertNodeSettingsGatesIfAbsent inserts a complete first-fill set in one transaction. A concurrent initializer may win the conditional insert for one or more names; in that case the transaction is rolled back so this method never leaves a partially initialized gate set behind.

func (*Store) IsCommitteeMemberResigned

func (s *Store) IsCommitteeMemberResigned(
	coldKey []byte,
	txn types.Txn,
) (bool, error)

func (*Store) IterateLiveUtxos

func (s *Store) IterateLiveUtxos(
	txn types.Txn,
	fn func(*models.Utxo) error,
) error

func (*Store) LatestPoolOpCertSequence

func (s *Store) LatestPoolOpCertSequence(
	poolKeyHash lcommon.PoolKeyHash,
	txn types.Txn,
) (uint64, bool, error)

func (*Store) LatestPoolOpCertSequences

func (s *Store) LatestPoolOpCertSequences(
	txn types.Txn,
) (map[string]uint64, error)

LatestPoolOpCertSequences returns the highest observed op-cert sequence for every pool that has issued a block, keyed by pool key hash.

The issuer table records one row per (pool, slot), so the highest sequence is an aggregate rather than the newest row: a pool that rotated to a lower issue number after a higher one has still had the higher number accepted, and that is the number the chain enforces.

func (*Store) MarkUtxosDeletedAtSlot

func (s *Store) MarkUtxosDeletedAtSlot(
	txn types.Txn,
	refs []types.UtxoKey,
	atSlot uint64,
) error

func (*Store) NewBatchAccumulator

func (s *Store) NewBatchAccumulator() types.MetadataBatchAccumulator

func (*Store) ReadPoolStats

func (s *Store) ReadPoolStats() sql.DBStats

ReadPoolStats exposes read-pool telemetry. SQLite file stores use this to report their independently-sized WAL reader pool.

func (*Store) ReadTransaction

func (s *Store) ReadTransaction() types.Txn

ReadTransaction begins a repeatable, read-only transaction on the read pool.

func (*Store) Ready

func (s *Store) Ready() bool

Ready reports whether startup migrations completed successfully.

func (*Store) RebuildRewardLiveStake

func (s *Store) RebuildRewardLiveStake(
	slot uint64,
	txn types.Txn,
) error

func (*Store) RecomputeGapCollateralFee

func (s *Store) RecomputeGapCollateralFee(
	transaction lcommon.Transaction,
	_ ocommon.Point,
	txn types.Txn,
) error

func (*Store) ReleaseFallbackRewardSnapshotGuard

func (s *Store) ReleaseFallbackRewardSnapshotGuard(
	guardID uint,
	txn types.Txn,
) error

func (*Store) RenewAccountExpirations

func (s *Store) RenewAccountExpirations(
	refs []models.StakeCredentialRef,
	expirationEpoch uint64,
	txn types.Txn,
) error

func (*Store) Reset added in v0.70.0

func (s *Store) Reset(ctx context.Context) error

Reset clears all data this store owns, for providers that supply the hook (see metadata.Resettable). A no-op for providers that don't -- unlike BackupTo/RestoreFrom, silently doing nothing here is correct, not a lost user request: sqlite (the only file-based provider built on this shared Store) has nothing for this to do, since restoreMetadataStore's directory wipe already fully undoes its brief resolve-and-start. Every backend built on this shared Store -- sqlite included -- therefore satisfies metadata.Resettable's interface, but only postgres/mysql wire a non-nil Config.Reset into it; sqlite's Reset is a documented no-op, not evidence that it "needs more than a directory wipe" the way metadata.Resettable's own doc comment describes for the backends that do.

func (*Store) ResetAccountExpirationActivation

func (s *Store) ResetAccountExpirationActivation(
	txn types.Txn,
) ([]models.StakeCredentialRef, error)

func (*Store) RestoreAccountStateAtSlot

func (s *Store) RestoreAccountStateAtSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) RestoreDrepStateAtSlot

func (s *Store) RestoreDrepStateAtSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) RestoreFrom

func (s *Store) RestoreFrom(ctx context.Context, srcPath string) error

func (*Store) RestoreNormalPragmas

func (s *Store) RestoreNormalPragmas() error

RestoreNormalPragmas restores safe backend defaults.

func (*Store) RestorePoolStateAtSlot

func (s *Store) RestorePoolStateAtSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) RetirePools

func (s *Store) RetirePools(
	txn types.Txn,
	poolKeyHashes [][]byte,
	epoch uint64,
	addedSlot uint64,
) error

func (*Store) RewardLiveStakeNeedsBackfill

func (s *Store) RewardLiveStakeNeedsBackfill(
	txn types.Txn,
) (bool, error)

func (*Store) SaveEpochSummary

func (s *Store) SaveEpochSummary(
	summary *models.EpochSummary,
	txn types.Txn,
) error

func (*Store) SavePoolStakeSnapshot

func (s *Store) SavePoolStakeSnapshot(
	snapshot *models.PoolStakeSnapshot,
	txn types.Txn,
) error

func (*Store) SavePoolStakeSnapshots

func (s *Store) SavePoolStakeSnapshots(
	snapshots []*models.PoolStakeSnapshot,
	txn types.Txn,
) error

func (*Store) SaveRewardAccountOutputs

func (s *Store) SaveRewardAccountOutputs(
	outputs []*models.RewardAccountOutput,
	txn types.Txn,
) error

func (*Store) SaveRewardAdaPots

func (s *Store) SaveRewardAdaPots(
	pots *models.RewardAdaPots,
	txn types.Txn,
) error

func (*Store) SaveRewardPoolInputs

func (s *Store) SaveRewardPoolInputs(
	inputs []*models.RewardPoolInput,
	txn types.Txn,
) error

func (*Store) SaveRewardPoolOutputs

func (s *Store) SaveRewardPoolOutputs(
	outputs []*models.RewardPoolOutput,
	txn types.Txn,
) error

func (*Store) SaveRewardSnapshot

func (s *Store) SaveRewardSnapshot(
	snapshot *models.RewardSnapshot,
	txn types.Txn,
) error

func (*Store) SaveRewardStakeInputs

func (s *Store) SaveRewardStakeInputs(
	inputs []*models.RewardStakeInput,
	txn types.Txn,
) error

func (*Store) SetBackfillCheckpoint

func (s *Store) SetBackfillCheckpoint(
	checkpoint *models.BackfillCheckpoint,
	txn types.Txn,
) error

func (*Store) SetBlockNonce

func (s *Store) SetBlockNonce(
	blockHash []byte,
	slotNumber uint64,
	nonce []byte,
	isCheckpoint bool,
	txn types.Txn,
) error

func (*Store) SetBulkLoadPragmas

func (s *Store) SetBulkLoadPragmas() error

SetBulkLoadPragmas enables backend-specific session tuning.

func (*Store) SetCommitTimestamp

func (s *Store) SetCommitTimestamp(
	timestamp int64,
	txn types.Txn,
) error

func (*Store) SetCommitteeMembers

func (s *Store) SetCommitteeMembers(
	members []*models.CommitteeMember,
	txn types.Txn,
) error

func (*Store) SetCommitteeQuorum

func (s *Store) SetCommitteeQuorum(
	quorum *types.Rat,
	slot uint64,
	txn types.Txn,
) error

func (*Store) SetConstitution

func (s *Store) SetConstitution(
	constitution *models.Constitution,
	txn types.Txn,
) error

func (*Store) SetDatum

func (s *Store) SetDatum(
	hash lcommon.Blake2b256,
	rawDatum []byte,
	addedSlot uint64,
	txn types.Txn,
) error

func (*Store) SetDrep

func (s *Store) SetDrep(
	credentialTag uint8,
	credential []byte,
	slot uint64,
	url string,
	hash []byte,
	active bool,
	txn types.Txn,
) error

SetDrep updates all mutable registration state. It remains a concrete store helper because existing callers use it even though it is not part of the public MetadataStore interface.

func (*Store) SetEpoch

func (s *Store) SetEpoch(
	slot, epoch uint64,
	nonce, evolvingNonce, candidateNonce, lastEpochBlockNonce []byte,
	era, slotLength, lengthInSlots uint,
	txn types.Txn,
) error

func (*Store) SetGapBlockTransaction

func (s *Store) SetGapBlockTransaction(
	transaction lcommon.Transaction,
	point ocommon.Point,
	index uint32,
	txn types.Txn,
) error

func (*Store) SetGenesisGovernance

func (s *Store) SetGenesisGovernance(
	initialDReps conway.ConwayGenesisInitialDReps,
	delegations conway.ConwayGenesisDelegs,
	_ []byte,
	txn types.Txn,
) error

func (*Store) SetGenesisStaking

func (s *Store) SetGenesisStaking(
	pools map[string]lcommon.PoolRegistrationCertificate,
	stakeDelegations map[string]string,
	_ []byte,
	txn types.Txn,
) error

func (*Store) SetGenesisTransaction

func (s *Store) SetGenesisTransaction(
	hash []byte,
	blockHash []byte,
	outputs []models.Utxo,
	txn types.Txn,
) error

func (*Store) SetGovernanceProposal

func (s *Store) SetGovernanceProposal(
	proposal *models.GovernanceProposal,
	txn types.Txn,
) error

func (*Store) SetGovernanceVote

func (s *Store) SetGovernanceVote(
	vote *models.GovernanceVote,
	txn types.Txn,
) error

func (*Store) SetImportCheckpoint

func (s *Store) SetImportCheckpoint(
	checkpoint *models.ImportCheckpoint,
	txn types.Txn,
) error

func (*Store) SetNetworkState

func (s *Store) SetNetworkState(
	treasury, reserves uint64,
	slot uint64,
	txn types.Txn,
) error

func (*Store) SetNodeSettings

func (s *Store) SetNodeSettings(settings *types.NodeSettings) error

func (*Store) SetNodeSettingsGates

func (s *Store) SetNodeSettingsGates(
	gates nodesettings.Values,
	recordedEpoch uint64,
	recordedSlot uint64,
) error

SetNodeSettingsGates persists gates, upserting one row per entry so a later call can overwrite an earlier one. recordedEpoch and recordedSlot are stamped on every row in this call; callers pass zero for both when the write happens before the first block. A nil or empty gates is a no-op.

func (*Store) SetOffchainMetadataFetchResult

func (s *Store) SetOffchainMetadataFetchResult(
	ctx context.Context,
	doc *models.OffchainMetadata,
	txn types.Txn,
) error

func (*Store) SetPParamUpdate

func (s *Store) SetPParamUpdate(
	genesis, update []byte,
	slot, epoch uint64,
	txn types.Txn,
) error

func (*Store) SetPParams

func (s *Store) SetPParams(
	params []byte,
	slot, epoch uint64,
	eraID uint,
	txn types.Txn,
) error

func (*Store) SetSyncState

func (s *Store) SetSyncState(
	key, value string,
	txn types.Txn,
) error

func (*Store) SetTip

func (s *Store) SetTip(tip ochainsync.Tip, txn types.Txn) error

func (*Store) SetTransaction

func (s *Store) SetTransaction(
	transaction lcommon.Transaction,
	point ocommon.Point,
	index uint32,
	certDeposits map[int]uint64,
	skipWithdrawalWitness bool,
	txn types.Txn,
) error

func (*Store) SetTransactionBatched

func (s *Store) SetTransactionBatched(
	transaction lcommon.Transaction,
	point ocommon.Point,
	index uint32,
	certDeposits map[int]uint64,
	skipWithdrawalWitness bool,
	accumulator types.MetadataBatchAccumulator,
	txn types.Txn,
) error

func (*Store) SetUtxoDeletedAtSlot

func (s *Store) SetUtxoDeletedAtSlot(
	input ledger.TransactionInput,
	slot uint64,
	spenderTxHash []byte,
	txn types.Txn,
) error

func (*Store) SetUtxosNotDeletedAfterSlot

func (s *Store) SetUtxosNotDeletedAfterSlot(
	slot uint64,
	txn types.Txn,
) error

func (*Store) SoftDeleteAllCommitteeMembers

func (s *Store) SoftDeleteAllCommitteeMembers(
	slot uint64,
	txn types.Txn,
) error

func (*Store) SoftDeleteCommitteeMembers

func (s *Store) SoftDeleteCommitteeMembers(
	coldCredHashes [][]byte,
	slot uint64,
	txn types.Txn,
) error

func (*Store) StaleConsensusStakeSnapshotsExist

func (s *Store) StaleConsensusStakeSnapshotsExist(
	txn types.Txn,
) (bool, error)

func (*Store) StampAllActiveAccountExpirations

func (s *Store) StampAllActiveAccountExpirations(
	expirationEpoch uint64,
	txn types.Txn,
) (int64, error)

func (*Store) Start

func (s *Store) Start(ctx context.Context) error

Start verifies connectivity and completes every offline migration before making the store available to normal readers or writers.

func (*Store) SumNetworkDonationsForEpoch

func (s *Store) SumNetworkDonationsForEpoch(
	epoch uint64,
	txn types.Txn,
) (uint64, error)

func (*Store) SumTransactionFeesInSlotRange

func (s *Store) SumTransactionFeesInSlotRange(
	startSlot uint64,
	endSlot uint64,
	txn types.Txn,
) (uint64, error)

func (*Store) Transaction

func (s *Store) Transaction() types.Txn

Transaction begins a write transaction. Begin failures are retained on the returned transaction because the historical MetadataStore contract cannot return an error from this method.

func (*Store) UpdateDRepActivity

func (s *Store) UpdateDRepActivity(
	credentialTag uint8,
	credential []byte,
	activityEpoch uint64,
	inactivityPeriod uint64,
	txn types.Txn,
) error

func (*Store) UpdatePlannerStats

func (s *Store) UpdatePlannerStats() error

UpdatePlannerStats refreshes backend planner statistics.

func (*Store) UpdatePoolOpCertSequence

func (s *Store) UpdatePoolOpCertSequence(
	poolKeyHash lcommon.PoolKeyHash,
	sequence uint64,
	slot uint64,
	txn types.Txn,
) error

func (*Store) UpsertMidnightAriadneParams

func (s *Store) UpsertMidnightAriadneParams(
	txn types.Txn,
	params *models.MidnightAriadneParams,
) error

func (*Store) UpsertMidnightEpochCandidates

func (s *Store) UpsertMidnightEpochCandidates(
	txn types.Txn,
	epochCandidates *models.MidnightEpochCandidates,
) error

func (*Store) ValidateBackup added in v0.70.0

func (s *Store) ValidateBackup(ctx context.Context, srcPath string) error

ValidateBackup checks a backup file's structural integrity, for providers that supply the hook (see metadata.BackupValidator). A no-op for providers that don't -- every backend built on this shared Store therefore satisfies metadata.BackupValidator's interface, but only providers whose restore orchestration needs it wire a non-nil Config.ValidateBackup in.

func (*Store) WritePoolStats

func (s *Store) WritePoolStats() sql.DBStats

WritePoolStats exposes database/sql pool telemetry without exposing the underlying database handle.

Directories

Path Synopsis
internal
Package migrations implements offline, forward-only metadata upgrades.
Package migrations implements offline, forward-only metadata upgrades.

Jump to

Keyboard shortcuts

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