sqlstore

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 37 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 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.

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
}

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(
	pattern models.UtxoAddressPattern,
	txn types.Txn,
) ([]models.Utxo, error)

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) 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) 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) 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,
	txn types.Txn,
) error

func (*Store) SetTransactionBatched

func (s *Store) SetTransactionBatched(
	transaction lcommon.Transaction,
	point ocommon.Point,
	index uint32,
	certDeposits map[int]uint64,
	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) 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