Documentation
¶
Index ¶
- Constants
- Variables
- func AppendUtxoAddressOrBranch(ors *[]string, args *[]any, addr ledger.Address) error
- func CredentialTagFromUint(tag uint) (uint8, error)
- func CredentialTagFromUint64(tag uint64) (uint8, error)
- func DedupePoolStakeSnapshots(db *gorm.DB, logger *slog.Logger) error
- func DrepTypeFromInt(drepType int) (uint64, error)
- func IsPhaseCompleted(checkpointPhase, queryPhase string) bool
- func MigrateAccountCredentialTagIndex(db *gorm.DB, logger *slog.Logger) error
- func MigrateAccountRewardDeltaCredentialTagIndex(db *gorm.DB, logger *slog.Logger) error
- func MigrateAccountRewardDeltaSlotIndex(db *gorm.DB, logger *slog.Logger) error
- func MigrateBlockNonceUniqueIndex(db *gorm.DB, logger *slog.Logger) error
- func MigrateDrepCredentialTagIndex(db *gorm.DB, logger *slog.Logger) error
- func MigrateGovernanceVoteCredentialTagIndex(db *gorm.DB, logger *slog.Logger) error
- func PaymentScriptFromAddress(addr ledger.Address) bool
- func StakeCredentialTagFromAddress(addr ledger.Address) (uint8, bool)
- func ValidatePredefinedDrepTypes(drepTypes []uint64) error
- type Account
- type AccountDelegationHistoryRow
- type AccountRegistrationHistoryRow
- type AccountRewardDelta
- type AccountSums
- type AddressTransaction
- type Asset
- type AuthCommitteeHot
- type BackfillCheckpoint
- type Block
- type BlockNonce
- type Certificate
- type CommitteeMember
- type CommitteeQuorum
- type Constitution
- type Datum
- type Deregistration
- type DeregistrationDrep
- type Drep
- type Epoch
- type EpochSummary
- type GovernanceProposal
- type GovernanceVote
- type ImportCheckpoint
- type KeyWitness
- type MIREffect
- type MIRReward
- type MidnightAriadneParams
- type MidnightAriadneRollback
- type MidnightAssetCreate
- type MidnightAssetSpend
- type MidnightDeregistration
- type MidnightEpochCandidates
- type MidnightGovernanceDatum
- type MidnightRegistration
- type MoveInstantaneousRewards
- type MoveInstantaneousRewardsReward
- type NetworkDonation
- type NetworkState
- type OffchainMetadata
- type PParamUpdate
- type PParams
- type PlutusData
- type Pool
- type PoolOpCertSequence
- type PoolRegistration
- type PoolRegistrationOwner
- type PoolRegistrationRelay
- type PoolRetirement
- type PoolRetirementRefund
- type PoolStakeSnapshot
- type Redeemer
- type Registration
- type RegistrationDrep
- type ResignCommitteeCold
- type RewardAdaPots
- type RewardPoolInput
- type RewardSnapshot
- type Script
- type StakeCredentialRef
- type StakeDelegation
- type StakeDeregistration
- type StakeRegistration
- type StakeRegistrationDelegation
- type StakeVoteDelegation
- type StakeVoteRegistrationDelegation
- type SyncState
- type Tip
- type Transaction
- type TransactionMetadataLabel
- type UpdateDrep
- type Utxo
- type UtxoId
- type UtxoOrderingCursor
- type UtxoSlot
- type UtxoWithOrdering
- type UtxoWithOrderingQuery
- type VoteDelegation
- type VoteRegistrationDelegation
- type WitnessScripts
Constants ¶
const ( DrepTypeAddrKeyHash uint64 = iota DrepTypeScriptHash DrepTypeAlwaysAbstain DrepTypeAlwaysNoConfidence )
const ( VoterTypeCC = 0 // Constitutional Committee member VoterTypeDRep = 1 // DRep VoterTypeSPO = 2 // Stake Pool Operator )
VoterType constants represent the type of voter casting a governance vote.
const ( VoteNo = 0 VoteYes = 1 VoteAbstain = 2 )
Vote constants represent the vote choice on a governance proposal.
const ( MidnightGovernanceDatumTypeTechnicalCommittee = "technical_committee" MidnightGovernanceDatumTypeCouncil = "council" )
const ( ImportPhaseUTxO = "utxo" ImportPhaseCertState = "certstate" ImportPhaseSnapshots = "snapshots" ImportPhasePParams = "pparams" ImportPhaseGovState = "gov_state" ImportPhaseTip = "tip" )
Import phases in execution order.
const ( OffchainMetadataSourcePool = "pool" OffchainMetadataSourceDrep = "drep" OffchainMetadataSourceDrepRegistration = "drep_registration" OffchainMetadataSourceDrepUpdate = "drep_update" OffchainMetadataSourceGovernanceProposal = "gov_proposal" OffchainMetadataSourceGovernanceVote = "gov_vote" OffchainMetadataSourceConstitution = "constitution" OffchainMetadataSourceCommitteeResign = "committee_resign" OffchainMetadataStatusPending = "pending" OffchainMetadataStatusFetched = "fetched" OffchainMetadataStatusFailed = "failed" )
const ( // PoolRewardAccountAutoVoteNone means the pool's reward account is // unset, deregistered, or delegated to anything other than the // predefined Always{Abstain,NoConfidence} DRep options. Such a // pool contributes to SPOTotalStake only and counts as implicit // no under CIP-1694. PoolRewardAccountAutoVoteNone uint8 = 0 // PoolRewardAccountAutoVoteAbstain means the pool's reward // account delegates to AlwaysAbstain at the snapshot epoch. Its // stake is bucketed into SPOAbstainStake (excluded from the // active denominator). PoolRewardAccountAutoVoteAbstain uint8 = 1 // PoolRewardAccountAutoVoteNoConfidence means the pool's reward // account delegates to AlwaysNoConfidence at the snapshot epoch. // For NoConfidence actions the pool stake is bucketed Yes; for // any other action type it is bucketed No (mirrors the // AlwaysNoConfidence DRep handling). PoolRewardAccountAutoVoteNoConfidence uint8 = 2 )
PoolRewardAccountAutoVote enumerates the CIP-1694 reward-account DRep-delegation outcomes that produce an implicit SPO vote when a pool did not cast an explicit vote on a proposal. Resolved and frozen at the epoch boundary that captures the stake snapshot so the governance tally uses snapshot-era state rather than live state.
const ( // KeyWitnessTypeVkey represents a Vkey witness KeyWitnessTypeVkey uint8 = 0 // KeyWitnessTypeBootstrap represents a Bootstrap witness KeyWitnessTypeBootstrap uint8 = 1 )
Variables ¶
var ( ErrDrepNotFound = errors.New("drep not found") // ErrDrepActivityNotUpdated is returned when an // UpdateDRepActivity call matches no DRep record. ErrDrepActivityNotUpdated = errors.New( "drep activity not updated: no matching record", ) )
var ( ErrNilUtxoWithOrderingQuery = errors.New( "nil UtxoWithOrderingQuery", ) ErrEmptyAssetPolicyID = errors.New("empty asset policy id") )
Sentinel errors for UtxoWithOrderingQuery validation.
var ErrAccountNotFound = errors.New("account not found")
var ErrBlockNotFound = errors.New("block not found")
var ErrCommitteeMemberNotFound = errors.New("committee member not found")
var ErrGovernanceProposalNotFound = errors.New("governance proposal not found")
var ErrPoolNotFound = errors.New("pool not found")
var ImportPhaseOrder = []string{ ImportPhaseUTxO, ImportPhaseCertState, ImportPhaseSnapshots, ImportPhasePParams, ImportPhaseGovState, ImportPhaseTip, }
ImportPhaseOrder defines the sequential order of import phases.
var MigrateModels = []any{ &Account{}, &AccountRewardDelta{}, &AddressTransaction{}, &Asset{}, &AuthCommitteeHot{}, &BackfillCheckpoint{}, &BlockNonce{}, &Certificate{}, &CommitteeMember{}, &CommitteeQuorum{}, &Constitution{}, &Datum{}, &Deregistration{}, &DeregistrationDrep{}, &Drep{}, &Epoch{}, &EpochSummary{}, &GovernanceProposal{}, &GovernanceVote{}, &ImportCheckpoint{}, &KeyWitness{}, &MoveInstantaneousRewards{}, &MoveInstantaneousRewardsReward{}, &MidnightAriadneParams{}, &MidnightAriadneRollback{}, &MidnightAssetCreate{}, &MidnightAssetSpend{}, &MidnightDeregistration{}, &MidnightEpochCandidates{}, &MidnightGovernanceDatum{}, &MidnightRegistration{}, &NetworkDonation{}, &NetworkState{}, &OffchainMetadata{}, &Pool{}, &PoolOpCertSequence{}, &PoolRegistration{}, &PoolRegistrationOwner{}, &PoolRegistrationRelay{}, &PoolRetirement{}, &PoolStakeSnapshot{}, &PParams{}, &PParamUpdate{}, &PlutusData{}, &Registration{}, &RegistrationDrep{}, &Redeemer{}, &RewardAdaPots{}, &RewardPoolInput{}, &RewardSnapshot{}, &ResignCommitteeCold{}, &Script{}, &StakeDelegation{}, &StakeDeregistration{}, &StakeRegistration{}, &StakeRegistrationDelegation{}, &StakeVoteDelegation{}, &StakeVoteRegistrationDelegation{}, &SyncState{}, &Tip{}, &Transaction{}, &TransactionMetadataLabel{}, &UpdateDrep{}, &Utxo{}, &VoteDelegation{}, &VoteRegistrationDelegation{}, &WitnessScripts{}, }
MigrateModels contains a list of model objects that should have DB migrations applied
Functions ¶
func AppendUtxoAddressOrBranch ¶ added in v0.34.0
AppendUtxoAddressOrBranch appends an OR branch for the given address to the ors/args slices. It uses standard "?" placeholders that work across SQLite, MySQL, and Postgres via GORM.
func CredentialTagFromUint ¶ added in v0.55.0
func CredentialTagFromUint64 ¶ added in v0.55.0
func DedupePoolStakeSnapshots ¶ added in v0.22.0
DedupePoolStakeSnapshots removes duplicate rows from the pool_stake_snapshot table so that the unique index idx_pool_stake_epoch_pool (epoch, snapshot_type, pool_key_hash) can be created safely by AutoMigrate. This must be called before AutoMigrate for PoolStakeSnapshot.
The function is a no-op when the table does not exist or contains no duplicates.
func DrepTypeFromInt ¶ added in v0.37.0
func IsPhaseCompleted ¶ added in v0.22.0
IsPhaseCompleted returns true if the given phase was completed in a previous import run (i.e., the checkpoint phase is at or past the given phase).
func MigrateAccountCredentialTagIndex ¶ added in v0.55.0
MigrateAccountCredentialTagIndex drops the legacy hash-only account uniqueness so AutoMigrate can create the tag-aware composite unique index.
func MigrateAccountRewardDeltaCredentialTagIndex ¶ added in v0.55.0
MigrateAccountRewardDeltaCredentialTagIndex drops the legacy unique index on account_reward_delta before AutoMigrate adds credential_tag to it. The old index covers (withdrawal, tx_hash, staking_key); the new one adds credential_tag so key and script reward accounts with the same hash are tracked independently.
func MigrateAccountRewardDeltaSlotIndex ¶ added in v0.58.0
MigrateAccountRewardDeltaSlotIndex drops the slot-less unique index on account_reward_delta so AutoMigrate can recreate it with added_slot included.
The old index (withdrawal, tx_hash, credential_tag, staking_key) keyed every credit delta without a per-event discriminator for an account onto a single row, so a second per-epoch credit — a MIR reward, a POOLREAP refund, or a governance deposit refund in a later epoch — collided on a clean first pass, and a crash-replayed epoch-rollover credit collided on restart. The new index idx_account_reward_delta_w_tx_s_slot adds added_slot so per-epoch credits are distinct rows while a replayed same-slot credit still maps to the same row (handled idempotently by the credit/withdrawal writers via OnConflict).
AutoMigrate does not alter an existing index in place, so the old index is dropped here by name; AutoMigrate then creates the renamed slot-aware index.
func MigrateBlockNonceUniqueIndex ¶ added in v0.37.0
MigrateBlockNonceUniqueIndex prepares the block_nonce table for the uniqueIndex:hash_slot tag introduced after the original non-unique index. AutoMigrate will not promote an existing non-unique index to unique, so an upgrading database keeps the legacy index and the new SetBlockNonce upsert (clause.OnConflict on hash+slot) fails because no matching unique constraint exists.
This helper deduplicates any (hash, slot) collisions, then drops the legacy non-unique index so AutoMigrate can recreate it as unique. It is a no-op when the table does not exist or the existing index is already unique.
func MigrateDrepCredentialTagIndex ¶ added in v0.55.0
MigrateDrepCredentialTagIndex drops the legacy hash-only DRep uniqueness constraint before AutoMigrate installs the tag-aware composite unique index.
func MigrateGovernanceVoteCredentialTagIndex ¶ added in v0.55.0
MigrateGovernanceVoteCredentialTagIndex drops the legacy vote uniqueness constraint before AutoMigrate installs the tag-aware composite unique index.
func PaymentScriptFromAddress ¶ added in v0.55.0
func StakeCredentialTagFromAddress ¶ added in v0.55.0
func ValidatePredefinedDrepTypes ¶ added in v0.37.0
ValidatePredefinedDrepTypes rejects credential-backed DRep delegation types. GetDRepVotingPowerByType is only for predefined, credentialless DRep options.
Types ¶
type Account ¶
type Account struct {
StakingKey []byte `` /* 224-byte string literal not displayed */
CredentialTag uint8 `` /* 235-byte string literal not displayed */
Pool []byte `gorm:"index;size:28;index:idx_account_active_pool_staking_key,priority:2"`
Drep []byte `gorm:"index;size:28;index:idx_account_drep_active_staking_key,priority:1"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
CertificateID uint `gorm:"index"`
Reward types.Uint64
// DrepType is the DRep delegation type code, an internal enum
// matching the Cardano ledger CBOR sum-type tag:
// 0 = key credential, 1 = script credential,
// 2 = AlwaysAbstain, 3 = AlwaysNoConfidence.
// A zero value (0) means either "key credential" or "no delegation set",
// disambiguated by whether Drep is nil.
DrepType uint64 `gorm:"default:0;index:idx_account_drep_type_active_staking_key,priority:1"`
Active bool `` /* 183-byte string literal not displayed */
}
type AccountDelegationHistoryRow ¶ added in v0.46.0
type AccountDelegationHistoryRow struct {
AddedSlot uint64
BlockIndex uint32
CertIndex uint32
TxHash []byte
PoolKeyHash []byte
// TxSlot is the slot of the transaction containing the
// delegation certificate.
TxSlot uint64
// BlockHash is the hash of the block containing the
// delegation certificate's transaction. The block height is
// resolved from the block store, which is not part of the
// metadata SQL schema.
BlockHash []byte
}
AccountDelegationHistoryRow holds delegation history query results for a stake account.
type AccountRegistrationHistoryRow ¶ added in v0.46.0
type AccountRegistrationHistoryRow struct {
AddedSlot uint64
BlockIndex uint32
CertIndex uint32
TxHash []byte
Action string
// Deposit is the registration deposit (or refund, for
// deregistrations) in lovelace. Zero for certificate types
// that do not record an explicit deposit.
Deposit uint64
// TxSlot is the slot of the transaction containing the
// (de)registration certificate.
TxSlot uint64
// BlockHash is the hash of the block containing the
// (de)registration certificate's transaction. The block
// height is resolved from the block store, which is not part
// of the metadata SQL schema.
BlockHash []byte
}
AccountRegistrationHistoryRow holds registration history query results for a stake account.
type AccountRewardDelta ¶ added in v0.37.0
type AccountRewardDelta struct {
StakingKey []byte `` /* 136-byte string literal not displayed */
CredentialTag uint8 `` /* 138-byte string literal not displayed */
TxHash []byte `gorm:"index;size:32;not null;uniqueIndex:idx_account_reward_delta_w_tx_s_slot,priority:2"`
Amount types.Uint64 `gorm:"not null"`
PreviousReward types.Uint64
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index;not null;uniqueIndex:idx_account_reward_delta_w_tx_s_slot,priority:5"`
Withdrawal bool `gorm:"index;not null;default:false;uniqueIndex:idx_account_reward_delta_w_tx_s_slot,priority:1"`
}
AccountRewardDelta records reward-account balance changes that are not otherwise represented by a rollback-aware certificate row. Credits store the credited Amount. Withdrawals store the withdrawal Amount, PreviousReward, and TxHash so rollback can restore the cleared reward balance.
The unique index idx_account_reward_delta_w_tx_s_slot includes AddedSlot. Withdrawal deltas are keyed by their (non-empty) TxHash, so each is unique regardless of slot. Credit deltas (deposit refunds, MIR, POOLREAP) use an event discriminator in TxHash when one is available and otherwise use the normalized empty value. Without AddedSlot, repeated per-epoch credits to a given account could still collapse onto a single row — colliding across epochs even on a clean first pass and breaking per-row rollback accounting in DeleteAccountRewardsAfterSlot. Including AddedSlot makes each per-epoch credit a distinct row while keeping a replayed epoch-rollover credit (same account, same event discriminator, same boundary slot) mapped to the same row so it can be skipped idempotently instead of erroring.
func (AccountRewardDelta) TableName ¶ added in v0.37.0
func (AccountRewardDelta) TableName() string
type AccountSums ¶ added in v0.59.0
type AccountSums struct {
// WithdrawalsSum is the total of all reward withdrawals
// made by the account.
WithdrawalsSum uint64
// ReservesSum is the total of all MIR transfers to the
// account sourced from the reserves pot.
ReservesSum uint64
// TreasurySum is the total of all MIR transfers to the
// account sourced from the treasury pot.
TreasurySum uint64
}
AccountSums holds aggregated lovelace totals for a stake account, summed from persisted withdrawal and MIR state.
type AddressTransaction ¶ added in v0.22.0
type AddressTransaction struct {
ID uint `gorm:"primaryKey"`
PaymentKey []byte `gorm:"index:idx_addr_tx_payment;size:28"`
StakingKey []byte `gorm:"index:idx_addr_tx_staking,priority:2;size:28"`
CredentialTag uint8 `gorm:"not null;default:0;index:idx_addr_tx_staking,priority:1"`
TransactionID uint `gorm:"index"`
Slot uint64 `gorm:"index"`
TxIndex uint32
}
AddressTransaction maps an address (payment and/or staking key) to a transaction that references it as an input/output participant.
func (AddressTransaction) TableName ¶ added in v0.22.0
func (AddressTransaction) TableName() string
type Asset ¶
type Asset struct {
Name []byte `gorm:"uniqueIndex:idx_asset_unique;size:32"`
NameHex []byte `gorm:"index;size:64"`
PolicyId []byte `gorm:"index:idx_asset_policy_id;uniqueIndex:idx_asset_unique;size:28"`
Fingerprint []byte `gorm:"index;size:48"`
ID uint `gorm:"primaryKey"`
UtxoID uint `gorm:"index;uniqueIndex:idx_asset_unique"`
Amount types.Uint64 `gorm:"index"`
}
func ConvertMultiAssetToModels ¶
func ConvertMultiAssetToModels( multiAsset *lcommon.MultiAsset[lcommon.MultiAssetTypeOutput], ) []Asset
ConvertMultiAssetToModels converts a MultiAsset structure into a slice of Asset models. Each asset is populated with its name, hex-encoded name, policy ID, fingerprint, and amount. Returns an empty slice if multiAsset is nil or contains no assets.
type AuthCommitteeHot ¶
type AuthCommitteeHot struct {
ColdCredential []byte `gorm:"index;size:28"`
// Column is "host_credential" for backward compatibility with
// existing databases; the Go field uses the canonical Cardano
// terminology ("hot credential" for committee voting keys).
HotCredential []byte `gorm:"column:host_credential;index;size:28"`
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
}
func (AuthCommitteeHot) TableName ¶
func (AuthCommitteeHot) TableName() string
type BackfillCheckpoint ¶ added in v0.22.0
type BackfillCheckpoint struct {
ID uint `gorm:"primarykey"`
Phase string `gorm:"uniqueIndex;size:64;not null"` // "metadata"
LastSlot uint64 // Last successfully processed slot
TotalSlots uint64 // Total slots to process (for progress)
StartedAt time.Time
UpdatedAt time.Time
Completed bool
}
BackfillCheckpoint tracks progress of automatic historical metadata backfill. After a Mithril bootstrap in API storage mode, stored blocks are replayed to populate transaction metadata. The checkpoint enables resumable progress if the process is interrupted.
func (BackfillCheckpoint) TableName ¶ added in v0.22.0
func (BackfillCheckpoint) TableName() string
type Block ¶
type BlockNonce ¶
type BlockNonce struct {
Hash []byte `gorm:"uniqueIndex:hash_slot;size:32"`
Nonce []byte
ID uint `gorm:"primarykey"`
Slot uint64 `gorm:"uniqueIndex:hash_slot"`
IsCheckpoint bool
}
func (BlockNonce) TableName ¶
func (BlockNonce) TableName() string
TableName overrides default table name
type Certificate ¶
type Certificate struct {
BlockHash []byte `gorm:"index;size:32"`
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"index;uniqueIndex:uniq_tx_cert"`
CertificateID uint `gorm:"index"` // Polymorphic FK to certificate table based on CertType. Not DB-enforced.
Slot uint64 `gorm:"index"`
CertIndex uint `gorm:"column:cert_index;uniqueIndex:uniq_tx_cert"`
CertType uint `gorm:"index"`
}
Certificate maps transaction certificates to their specialized table records. Provides unified indexing across all certificate types without requiring joins.
All certificate types now have dedicated specialized models. The CertificateID field references the ID of the specific certificate record based on CertType.
func (Certificate) TableName ¶
func (Certificate) TableName() string
func (Certificate) Type ¶
func (c Certificate) Type() uint
type CommitteeMember ¶ added in v0.22.0
type CommitteeMember struct {
ID uint `gorm:"primarykey"`
ColdCredHash []byte `gorm:"uniqueIndex;size:28;not null"` // 28-byte credential hash
ExpiresEpoch uint64 `gorm:"not null"`
AddedSlot uint64 `gorm:"index;not null"` // Slot when imported/registered
DeletedSlot *uint64 `gorm:"index"` // For rollback support
}
CommitteeMember represents a Constitutional Committee member imported from a Mithril snapshot. This is separate from the certificate-based AuthCommitteeHot/ResignCommitteeCold tables, which track committee membership changes from on-chain certificates. This table captures the committee composition at the time of the snapshot.
func (CommitteeMember) TableName ¶ added in v0.22.0
func (CommitteeMember) TableName() string
TableName returns the table name for CommitteeMember.
type CommitteeQuorum ¶ added in v0.37.0
type CommitteeQuorum struct {
Quorum *types.Rat
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"uniqueIndex;not null"`
}
CommitteeQuorum records the quorum threshold enacted with a committee.
func (CommitteeQuorum) TableName ¶ added in v0.37.0
func (CommitteeQuorum) TableName() string
TableName returns the table name for CommitteeQuorum.
type Constitution ¶ added in v0.22.0
type Constitution struct {
ID uint `gorm:"primarykey"`
AnchorURL string `gorm:"column:anchor_url;size:128;not null"`
AnchorHash []byte `gorm:"size:32;not null"`
PolicyHash []byte `gorm:"size:28"`
AddedSlot uint64 `gorm:"uniqueIndex;not null"`
DeletedSlot *uint64 `gorm:"index"`
}
Constitution represents the on-chain constitution document reference. The constitution is established via governance action and contains a URL and hash pointing to the full document, plus an optional guardrails script.
func (Constitution) TableName ¶ added in v0.22.0
func (Constitution) TableName() string
TableName returns the table name
type Datum ¶
type Deregistration ¶
type Deregistration struct {
StakingKey []byte `gorm:"index:idx_deregistration_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_deregistration_credential,priority:1;not null;default:0"`
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
Amount types.Uint64
}
func (Deregistration) TableName ¶
func (Deregistration) TableName() string
type DeregistrationDrep ¶
type DeregistrationDrep struct {
DrepCredential []byte `gorm:"index:idx_dereg_drep_credential,priority:2;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
CredentialTag uint8 `gorm:"index:idx_dereg_drep_credential,priority:1;not null;default:0"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (DeregistrationDrep) TableName ¶
func (DeregistrationDrep) TableName() string
type Drep ¶
type Drep struct {
AnchorURL string `gorm:"column:anchor_url;size:128"`
Credential []byte `gorm:"uniqueIndex:idx_drep_credential,priority:2;size:28"`
AnchorHash []byte
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
CredentialTag uint8 `gorm:"uniqueIndex:idx_drep_credential,priority:1;not null;default:0"`
// Last activity epoch (vote, register, update).
LastActivityEpoch uint64 `gorm:"index;default:0"`
// Epoch when DRep expires (activity + inactivity).
ExpiryEpoch uint64 `gorm:"index;default:0"`
Active bool `gorm:"default:true"`
}
type Epoch ¶
type Epoch struct {
Nonce []byte
EvolvingNonce []byte
// CandidateNonce holds the frozen candidate nonce from the end
// of the previous epoch (psCandidateNonce in Haskell). In
// Ouroboros Praos, the candidate nonce tracks the evolving
// nonce until the randomness stabilisation window cutoff
// (4k/f slots before the end of the epoch), then freezes.
// When 4k/f >= epochLength (e.g., devnets with short epochs),
// the candidate nonce is never updated and stays at its
// initial value (genesis hash). This field carries the
// candidate nonce across epochs so it can seed the next
// epoch's computation correctly.
CandidateNonce []byte
// LastEpochBlockNonce holds the prevHash of the last applied
// block from the PREVIOUS epoch transition (praosStateLabNonce
// in Haskell). In Ouroboros Praos, the epoch nonce formula uses
// a lagged lab nonce: at the N→N+1 transition, the nonce saved
// at N-1→N is used. This field is nil for epoch 0 (equivalent
// to NeutralNonce / identity).
LastEpochBlockNonce []byte
ID uint `gorm:"primarykey"`
// NOTE: we would normally use this as the primary key, but GORM doesn't
// like a primary key value of 0
EpochId uint64 `gorm:"uniqueIndex"`
StartSlot uint64
EraId uint
SlotLength uint
LengthInSlots uint
}
type EpochSummary ¶ added in v0.21.0
type EpochSummary struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex;not null"`
TotalActiveStake types.Uint64 `gorm:"not null"`
TotalPoolCount uint64 `gorm:"not null"`
TotalDelegators uint64 `gorm:"not null"`
EpochNonce []byte `gorm:"size:32"`
BoundarySlot uint64 `gorm:"not null"`
SnapshotReady bool `gorm:"not null;default:false"`
}
EpochSummary captures network-wide aggregate statistics at epoch boundary.
func (EpochSummary) TableName ¶ added in v0.21.0
func (EpochSummary) TableName() string
TableName returns the table name
type GovernanceProposal ¶ added in v0.22.0
type GovernanceProposal struct {
ID uint `gorm:"primarykey"`
TxHash []byte `gorm:"uniqueIndex:idx_proposal_tx_action,priority:1;size:32;not null"`
ActionIndex uint32 `gorm:"uniqueIndex:idx_proposal_tx_action,priority:2;not null"`
ActionType uint8 `gorm:"index;not null"` // GovActionType enum
ProposedEpoch uint64 `gorm:"index;not null"`
ExpiresEpoch uint64 `gorm:"index;not null"`
ParentTxHash []byte `gorm:"index:idx_gov_proposal_parent,priority:1;size:32"`
ParentActionIdx *uint32 `gorm:"index:idx_gov_proposal_parent,priority:2"`
EnactedEpoch *uint64
EnactedSlot *uint64 `gorm:"index"` // Slot when enacted (for rollback safety)
RatifiedEpoch *uint64
RatifiedSlot *uint64 `gorm:"index"` // Slot when ratified (for rollback safety)
PolicyHash []byte `gorm:"size:28"`
AnchorURL string `gorm:"column:anchor_url;size:128;not null"`
AnchorHash []byte `gorm:"size:32;not null"`
Deposit uint64 `gorm:"not null"`
ReturnAddress []byte `gorm:"size:29;not null"` // Reward account for deposit return (1 byte header + 28 bytes hash)
// GovActionCbor holds the CBOR-encoded GovAction needed at enactment
// time to extract type-specific fields (ParamUpdate, ProtocolVersion,
// Withdrawals, Committee changes, Constitution). Populated on proposal
// submission so enactment does not need to re-fetch the transaction.
GovActionCbor []byte
ExpiredEpoch *uint64 `gorm:"index"`
ExpiredSlot *uint64 `gorm:"index"` // Slot when expired (for rollback safety)
AddedSlot uint64 `gorm:"index;not null"`
DeletedSlot *uint64 `gorm:"index"`
}
GovernanceProposal represents a governance action submitted to the chain. Proposals have a lifecycle: submitted -> (ratified) -> (enacted) or expired.
func (GovernanceProposal) TableName ¶ added in v0.22.0
func (GovernanceProposal) TableName() string
TableName returns the table name
type GovernanceVote ¶ added in v0.22.0
type GovernanceVote struct {
ID uint `gorm:"primarykey"`
ProposalID uint `gorm:"index:idx_vote_proposal;uniqueIndex:idx_vote_unique,priority:1;not null"`
VoterType uint8 `gorm:"index:idx_vote_voter,priority:1;uniqueIndex:idx_vote_unique,priority:2;not null"` // 0=CC, 1=DRep, 2=SPO
VoterCredentialTag uint8 `gorm:"index:idx_vote_voter,priority:2;uniqueIndex:idx_vote_unique,priority:3;not null;default:0"`
VoterCredential []byte `gorm:"index:idx_vote_voter,priority:3;uniqueIndex:idx_vote_unique,priority:4;size:28;not null"`
Vote uint8 `gorm:"not null"` // 0=No, 1=Yes, 2=Abstain
AnchorURL string `gorm:"column:anchor_url;size:128"`
AnchorHash []byte `gorm:"size:32"`
AddedSlot uint64 `gorm:"index;not null"`
// Slot when vote was last changed (for rollback safety).
VoteUpdatedSlot *uint64 `gorm:"index"`
DeletedSlot *uint64 `gorm:"index"`
}
GovernanceVote represents a vote cast by a Constitutional Committee member, DRep, or Stake Pool Operator on a governance proposal.
func (GovernanceVote) TableName ¶ added in v0.22.0
func (GovernanceVote) TableName() string
TableName returns the table name
type ImportCheckpoint ¶ added in v0.22.0
type ImportCheckpoint struct {
ID uint `gorm:"primarykey"`
ImportKey string `gorm:"size:255;uniqueIndex;not null"` // "{digest}:{slot}"
Phase string `gorm:"not null"` // last completed phase
}
ImportCheckpoint tracks the progress of a Mithril snapshot import so that it can be resumed after a failure without re-importing already completed phases.
func (ImportCheckpoint) TableName ¶ added in v0.22.0
func (ImportCheckpoint) TableName() string
type KeyWitness ¶
type KeyWitness struct {
Vkey []byte
Signature []byte
PublicKey []byte
ChainCode []byte
Attributes []byte
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"index"`
Type uint8 `gorm:"index"`
}
KeyWitness represents a key witness entry (Vkey or Bootstrap) Type: KeyWitnessTypeVkey = VkeyWitness, KeyWitnessTypeBootstrap = BootstrapWitness
func (KeyWitness) TableName ¶
func (KeyWitness) TableName() string
type MIREffect ¶ added in v0.55.0
type MIREffect struct {
// ID is the move_instantaneous_rewards row ID. It is used as the stable
// per-MIR reward-credit discriminator when applying epoch-boundary effects.
ID uint
// Pot is the source Ada pot: 0 = Reserves, 1 = Treasury.
Pot uint
// OtherPot is the amount for a pot-to-pot transfer (0 when distributing).
OtherPot uint64
// Rewards lists credential→amount pairs for a distribution MIR.
Rewards []MIRReward
}
MIREffect is the processed form of a single MIR certificate used by the epoch-boundary application logic. One of OtherPot > 0 (pot-to-pot transfer) or len(Rewards) > 0 (credential distribution) will be non-empty.
type MIRReward ¶ added in v0.55.0
MIRReward is a single credential→amount entry from a distribution MIR cert.
type MidnightAriadneParams ¶ added in v0.55.0
type MidnightAriadneParams struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex;not null"`
Datum []byte `gorm:"not null"`
}
MidnightAriadneParams stores Ariadne parameters per epoch when changed.
func (MidnightAriadneParams) TableName ¶ added in v0.55.0
func (MidnightAriadneParams) TableName() string
type MidnightAriadneRollback ¶ added in v0.61.0
type MidnightAriadneRollback struct {
ID uint `gorm:"primarykey"`
BlockNumber uint64 `gorm:"uniqueIndex:idx_midnight_ariadne_rollbacks_block_epoch,priority:1;not null"`
Epoch uint64 `gorm:"uniqueIndex:idx_midnight_ariadne_rollbacks_block_epoch,priority:2;not null"`
PreviousExists bool `gorm:"not null"`
PreviousDatum []byte
}
MidnightAriadneRollback stores the previous Ariadne row for a block upsert, so a later rollback can restore state even after process restart.
func (MidnightAriadneRollback) TableName ¶ added in v0.61.0
func (MidnightAriadneRollback) TableName() string
type MidnightAssetCreate ¶ added in v0.55.0
type MidnightAssetCreate struct {
ID uint `gorm:"primarykey"`
Address []byte `gorm:"not null"`
Quantity uint64 `gorm:"not null"`
TxHash []byte `gorm:"uniqueIndex:idx_midnight_asset_creates_utxo_lookup,priority:1;size:32;not null"`
OutputIndex uint32 `gorm:"uniqueIndex:idx_midnight_asset_creates_utxo_lookup,priority:2;not null"`
BlockNumber uint64 `gorm:"index:idx_midnight_asset_creates_block_tx,priority:1;not null"`
BlockHash []byte `gorm:"size:32;not null"`
TxIndex uint32 `gorm:"index:idx_midnight_asset_creates_block_tx,priority:2;not null"`
BlockTimestampMs uint64 `gorm:"not null"`
}
MidnightAssetCreate stores cNIGHT UTxO creations for the Midnight indexer.
func (MidnightAssetCreate) TableName ¶ added in v0.55.0
func (MidnightAssetCreate) TableName() string
type MidnightAssetSpend ¶ added in v0.55.0
type MidnightAssetSpend struct {
ID uint `gorm:"primarykey"`
Address []byte `gorm:"not null"`
Quantity uint64 `gorm:"not null"`
SpendingTxHash []byte `gorm:"size:32;not null"`
UtxoTxHash []byte `gorm:"uniqueIndex:idx_midnight_asset_spends_utxo_ref,priority:1;size:32;not null"`
UtxoIndex uint32 `gorm:"uniqueIndex:idx_midnight_asset_spends_utxo_ref,priority:2;not null"`
BlockNumber uint64 `gorm:"index:idx_midnight_asset_spends_block_tx,priority:1;not null"`
BlockHash []byte `gorm:"size:32;not null"`
TxIndex uint32 `gorm:"index:idx_midnight_asset_spends_block_tx,priority:2;not null"`
BlockTimestampMs uint64 `gorm:"not null"`
}
MidnightAssetSpend stores cNIGHT UTxO spends for the Midnight indexer.
func (MidnightAssetSpend) TableName ¶ added in v0.55.0
func (MidnightAssetSpend) TableName() string
type MidnightDeregistration ¶ added in v0.55.0
type MidnightDeregistration struct {
ID uint `gorm:"primarykey"`
FullDatum []byte `gorm:"not null"`
TxHash []byte `gorm:"size:32;not null"`
UtxoTxHash []byte `gorm:"uniqueIndex:idx_midnight_deregistrations_utxo_ref,priority:1;size:32;not null"`
UtxoIndex uint32 `gorm:"uniqueIndex:idx_midnight_deregistrations_utxo_ref,priority:2;not null"`
BlockNumber uint64 `gorm:"index:idx_midnight_deregistrations_block_tx,priority:1;not null"`
BlockHash []byte `gorm:"size:32;not null"`
TxIndex uint32 `gorm:"index:idx_midnight_deregistrations_block_tx,priority:2;not null"`
BlockTimestampMs uint64 `gorm:"not null"`
}
MidnightDeregistration stores mapping validator deregistration events.
func (MidnightDeregistration) TableName ¶ added in v0.55.0
func (MidnightDeregistration) TableName() string
type MidnightEpochCandidates ¶ added in v0.55.0
type MidnightEpochCandidates struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex;not null"`
BlockNumber uint64 `gorm:"index;not null;default:0"`
CandidatesCbor []byte `gorm:"not null"`
}
MidnightEpochCandidates stores candidate snapshots at epoch boundaries.
func (MidnightEpochCandidates) TableName ¶ added in v0.55.0
func (MidnightEpochCandidates) TableName() string
type MidnightGovernanceDatum ¶ added in v0.55.0
type MidnightGovernanceDatum struct {
ID uint `gorm:"primarykey"`
DatumType string `` /* 139-byte string literal not displayed */
TxHash []byte `gorm:"uniqueIndex:idx_midnight_governance_datums_output,priority:2;size:32;not null"`
OutputIndex uint32 `gorm:"uniqueIndex:idx_midnight_governance_datums_output,priority:3;not null"`
Datum []byte `gorm:"not null"`
BlockNumber uint64 `gorm:"index:idx_midnight_governance_datums_latest,priority:2,sort:desc;not null"`
}
MidnightGovernanceDatum stores latest Technical Committee and Council datums.
func (MidnightGovernanceDatum) TableName ¶ added in v0.55.0
func (MidnightGovernanceDatum) TableName() string
type MidnightRegistration ¶ added in v0.55.0
type MidnightRegistration struct {
ID uint `gorm:"primarykey"`
FullDatum []byte `gorm:"not null"`
TxHash []byte `gorm:"uniqueIndex:idx_midnight_registrations_utxo_lookup,priority:1;size:32;not null"`
OutputIndex uint32 `gorm:"uniqueIndex:idx_midnight_registrations_utxo_lookup,priority:2;not null"`
BlockNumber uint64 `gorm:"index:idx_midnight_registrations_block_tx,priority:1;not null"`
BlockHash []byte `gorm:"size:32;not null"`
TxIndex uint32 `gorm:"index:idx_midnight_registrations_block_tx,priority:2;not null"`
BlockTimestampMs uint64 `gorm:"not null"`
}
MidnightRegistration stores mapping validator registration events.
func (MidnightRegistration) TableName ¶ added in v0.55.0
func (MidnightRegistration) TableName() string
type MoveInstantaneousRewards ¶
type MoveInstantaneousRewards struct {
Rewards []MoveInstantaneousRewardsReward `gorm:"foreignKey:MIRID;constraint:OnDelete:CASCADE"`
Pot uint `gorm:"index"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
// OtherPot holds the lovelace amount for a pot-to-pot transfer (non-zero
// only when the cert moves coins between treasury and reserves rather than
// distributing to staking credentials).
OtherPot types.Uint64 `gorm:"default:0"`
}
func (MoveInstantaneousRewards) TableName ¶
func (MoveInstantaneousRewards) TableName() string
type MoveInstantaneousRewardsReward ¶
type MoveInstantaneousRewardsReward struct {
Credential []byte `gorm:"index:idx_mir_reward_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_mir_reward_credential,priority:1;not null;default:0"`
Amount types.Uint64
ID uint `gorm:"primarykey"`
MIRID uint `gorm:"index"`
}
func (MoveInstantaneousRewardsReward) TableName ¶
func (MoveInstantaneousRewardsReward) TableName() string
type NetworkDonation ¶ added in v0.55.0
type NetworkDonation struct {
ID uint `gorm:"primarykey"`
Slot uint64 `gorm:"uniqueIndex;not null"`
Epoch uint64 `gorm:"index;not null"`
Amount uint64 `gorm:"not null"`
}
NetworkDonation records the total Conway treasury donation contributed by a block, tagged with the epoch the block belongs to. Donations accumulate during an epoch and are moved into the treasury at the next epoch boundary (see NetworkState). Rows are keyed by slot so a chain rollback can drop them with DeleteNetworkDonationsAfterSlot, mirroring NetworkState.
Amount is a plain uint64 (stored as an integer, like Slot/Epoch) rather than types.Uint64: donation totals are bounded well below 2^63, so an integer column lets SUM aggregate directly across SQLite/Postgres/MySQL without the per-backend CAST that the text-encoded types.Uint64 would require.
func (NetworkDonation) TableName ¶ added in v0.55.0
func (NetworkDonation) TableName() string
TableName returns the table name for NetworkDonation.
type NetworkState ¶ added in v0.22.0
type NetworkState struct {
ID uint `gorm:"primarykey"`
Treasury types.Uint64 `gorm:"not null"`
Reserves types.Uint64 `gorm:"not null"`
Slot uint64 `gorm:"uniqueIndex;not null"`
}
NetworkState stores treasury and reserves balances at a given slot.
func (NetworkState) TableName ¶ added in v0.22.0
func (NetworkState) TableName() string
TableName returns the table name for NetworkState.
type OffchainMetadata ¶ added in v0.54.0
type OffchainMetadata struct {
FetchedAt *time.Time
NextFetchAfter *time.Time `gorm:"index:idx_offchain_metadata_status_next,priority:2"`
CreatedAt time.Time
UpdatedAt time.Time
URL string `gorm:"size:512;not null;uniqueIndex:idx_offchain_metadata_source_url_hash,priority:2"`
SourceType string `gorm:"size:32;not null;uniqueIndex:idx_offchain_metadata_source_url_hash,priority:1"`
Status string `gorm:"size:16;not null;index:idx_offchain_metadata_status_next,priority:1"`
ContentType string `gorm:"size:128"`
LastError string `gorm:"size:1024"`
Hash []byte `gorm:"size:32;not null;uniqueIndex:idx_offchain_metadata_source_url_hash,priority:3"`
BodyHash []byte `gorm:"size:32"`
Content []byte
ID uint `gorm:"primarykey"`
FetchAttempts uint
LastHTTPStatus uint
}
OffchainMetadata stores a fetched copy of content referenced by on-chain metadata and governance anchors. The on-chain URL/hash pair remains authoritative; this table is a best-effort API cache.
func (OffchainMetadata) TableName ¶ added in v0.54.0
func (OffchainMetadata) TableName() string
type PParamUpdate ¶
type PParamUpdate struct {
GenesisHash []byte
Cbor []byte
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
Epoch uint64
}
func (PParamUpdate) TableName ¶
func (PParamUpdate) TableName() string
type PParams ¶
type PlutusData ¶
type PlutusData struct {
Transaction *Transaction `gorm:"foreignKey:TransactionID"`
Data []byte
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"index"`
}
PlutusData represents a Plutus data value in the witness set
func (PlutusData) TableName ¶
func (PlutusData) TableName() string
type Pool ¶
type Pool struct {
Margin *types.Rat
PoolKeyHash []byte `gorm:"uniqueIndex;size:28"`
VrfKeyHash []byte
RewardAccount []byte
LatestOpCertSequence uint64
// RewardAccountCredentialTag is the stake credential type of the pool's
// reward account: 0 = key hash, 1 = script hash. The on-chain pool cert
// encodes the reward_account as a 29-byte reward address (header + 28-byte
// hash). The gouroboros library stores only the first 28 bytes in
// RewardAccount (AddrKeyHash), discarding the header. We decode the raw
// cert CBOR to preserve the credential type here.
RewardAccountCredentialTag uint8 `gorm:"not null;default:0"`
// Owners and Relays are query-only associations (no CASCADE).
// The actual parent-child relationship is PoolRegistration -> Owners/Relays.
// When Pool is deleted, PoolRegistrations cascade, which then cascade to Owners/Relays.
Owners []PoolRegistrationOwner `gorm:"foreignKey:PoolID"`
Relays []PoolRegistrationRelay `gorm:"foreignKey:PoolID"`
Registration []PoolRegistration `gorm:"foreignKey:PoolID;constraint:OnDelete:CASCADE"`
Retirement []PoolRetirement `gorm:"foreignKey:PoolID;constraint:OnDelete:CASCADE"`
ID uint `gorm:"primarykey"`
Pledge types.Uint64
Cost types.Uint64
}
Error 1170 (42000): BLOB/TEXT column 'staking_key' used in key specification without a key length
type PoolOpCertSequence ¶ added in v0.46.0
type PoolOpCertSequence struct {
PoolKeyHash []byte `gorm:"uniqueIndex:idx_pool_opcert_sequence_pool_slot;size:28"`
ID uint `gorm:"primarykey"`
Slot uint64 `gorm:"uniqueIndex:idx_pool_opcert_sequence_pool_slot;index"`
Sequence uint64
}
func (PoolOpCertSequence) TableName ¶ added in v0.46.0
func (PoolOpCertSequence) TableName() string
type PoolRegistration ¶
type PoolRegistration struct {
Margin *types.Rat
Pool *Pool // Belongs-to relationship; CASCADE is defined on Pool.Registration
MetadataUrl string
VrfKeyHash []byte
PoolKeyHash []byte `gorm:"index;size:28"`
RewardAccount []byte
RewardAccountCredentialTag uint8 `gorm:"not null;default:0"`
MetadataHash []byte
Owners []PoolRegistrationOwner `gorm:"foreignKey:PoolRegistrationID;constraint:OnDelete:CASCADE"`
Relays []PoolRegistrationRelay `gorm:"foreignKey:PoolRegistrationID;constraint:OnDelete:CASCADE"`
Pledge types.Uint64
Cost types.Uint64
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
PoolID uint `gorm:"uniqueIndex:idx_pool_reg_pool_slot"`
AddedSlot uint64 `gorm:"uniqueIndex:idx_pool_reg_pool_slot"`
DepositAmount types.Uint64
}
func (PoolRegistration) TableName ¶
func (PoolRegistration) TableName() string
type PoolRegistrationOwner ¶
type PoolRegistrationOwner struct {
KeyHash []byte
ID uint `gorm:"primarykey"`
PoolRegistrationID uint `gorm:"index"`
PoolID uint `gorm:"index"`
}
func (PoolRegistrationOwner) TableName ¶
func (PoolRegistrationOwner) TableName() string
type PoolRegistrationRelay ¶
type PoolRegistrationRelay struct {
Ipv4 *net.IP
Ipv6 *net.IP
Hostname string
ID uint `gorm:"primarykey"`
PoolRegistrationID uint `gorm:"index"`
PoolID uint `gorm:"index"`
Port uint
}
func (PoolRegistrationRelay) TableName ¶
func (PoolRegistrationRelay) TableName() string
type PoolRetirement ¶
type PoolRetirement struct {
PoolKeyHash []byte `gorm:"index;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
PoolID uint `gorm:"index"`
Epoch uint64
AddedSlot uint64 `gorm:"index"`
}
func (PoolRetirement) TableName ¶
func (PoolRetirement) TableName() string
type PoolRetirementRefund ¶ added in v0.55.0
type PoolRetirementRefund struct {
PoolKeyHash []byte
RewardAccount []byte
RewardAccountCredentialTag uint8
DepositAmount types.Uint64
}
PoolRetirementRefund identifies a pool retiring at an epoch boundary along with the reward account and deposit needed to refund its POOLREAP deposit. It is a query result, not a persisted table.
type PoolStakeSnapshot ¶ added in v0.21.0
type PoolStakeSnapshot struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex:idx_pool_stake_epoch_pool,priority:1;not null"`
SnapshotType string `gorm:"type:varchar(4);uniqueIndex:idx_pool_stake_epoch_pool,priority:2;not null"` // "mark", "set", "go"
PoolKeyHash []byte `gorm:"uniqueIndex:idx_pool_stake_epoch_pool,priority:3;size:28;not null"`
TotalStake types.Uint64 `gorm:"not null"`
DelegatorCount uint64 `gorm:"not null"`
CapturedSlot uint64 `gorm:"not null"`
// RewardAccountAutoVote captures the CIP-1694 SPO auto-vote
// outcome implied by the pool's reward-account DRep delegation at
// the snapshot epoch. Values come from PoolRewardAccountAutoVote*.
// This field is only meaningful when RewardAccountAutoVoteResolved
// is true; otherwise its value is undefined and must not be read
// by the tally.
RewardAccountAutoVote uint8 `gorm:"not null;default:0"`
// RewardAccountAutoVoteResolved disambiguates "resolved as none"
// from "never resolved". The resolver sets this to true after it
// has computed RewardAccountAutoVote against snapshot-era state.
// Rows imported by Mithril for set/go rotations (which only have
// live state available at import time and cannot be faithfully
// resolved against historical boundaries) intentionally leave this
// false; the tally treats them as PoolRewardAccountAutoVoteNone,
// matching pre-CIP-1694 behaviour for those rows. Pre-CIP-1694
// rows in upgraded databases also remain false until re-resolved.
RewardAccountAutoVoteResolved bool `gorm:"not null;default:false"`
}
PoolStakeSnapshot captures aggregated pool stake at an epoch boundary. Used for leader election in Ouroboros Praos consensus.
func (PoolStakeSnapshot) TableName ¶ added in v0.21.0
func (PoolStakeSnapshot) TableName() string
TableName returns the table name
type Redeemer ¶
type Redeemer struct {
Data []byte
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"index"`
ExUnitsMemory uint64
ExUnitsCPU uint64
Index uint32 `gorm:"index"`
Tag uint8 `gorm:"index"`
}
Redeemer represents a redeemer in the witness set
type Registration ¶
type Registration struct {
StakingKey []byte `gorm:"index:idx_registration_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_registration_credential,priority:1;not null;default:0"`
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (Registration) TableName ¶
func (Registration) TableName() string
type RegistrationDrep ¶
type RegistrationDrep struct {
AnchorURL string `gorm:"column:anchor_url;size:128"`
DrepCredential []byte `gorm:"uniqueIndex:idx_drep_reg_cred_slot,priority:2;size:28"`
AnchorHash []byte
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
CredentialTag uint8 `gorm:"uniqueIndex:idx_drep_reg_cred_slot,priority:1;not null;default:0"`
AddedSlot uint64 `gorm:"uniqueIndex:idx_drep_reg_cred_slot,priority:3"`
DepositAmount types.Uint64
}
func (RegistrationDrep) TableName ¶
func (RegistrationDrep) TableName() string
type ResignCommitteeCold ¶
type ResignCommitteeCold struct {
AnchorURL string `gorm:"column:anchor_url;size:128"`
ColdCredential []byte `gorm:"index;size:28"`
AnchorHash []byte
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
}
ResignCommitteeCold represents a resignation certificate for a Constitutional Committee cold credential.
func (ResignCommitteeCold) TableName ¶
func (ResignCommitteeCold) TableName() string
TableName returns the table name
type RewardAdaPots ¶ added in v0.49.0
type RewardAdaPots struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex;not null"`
Treasury types.Uint64 `gorm:"not null"`
Reserves types.Uint64 `gorm:"not null"`
Fees types.Uint64 `gorm:"not null"`
Rewards types.Uint64 `gorm:"not null"`
CapturedSlot uint64 `gorm:"index;not null"`
}
RewardAdaPots captures the reward-related ADA pots at an epoch boundary.
func (RewardAdaPots) TableName ¶ added in v0.49.0
func (RewardAdaPots) TableName() string
type RewardPoolInput ¶ added in v0.49.0
type RewardPoolInput struct {
Margin *types.Rat
PoolKeyHash []byte `gorm:"uniqueIndex:idx_reward_pool_input_epoch_pool,priority:2;size:28;not null"`
BlocksProduced *uint64
TotalBlocksInEpoch *uint64
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex:idx_reward_pool_input_epoch_pool,priority:1;not null"`
Pledge types.Uint64 `gorm:"not null"`
DelegatedStake types.Uint64 `gorm:"not null"`
Cost types.Uint64 `gorm:"not null"`
DelegatorCount uint64 `gorm:"not null"`
CapturedSlot uint64 `gorm:"index;not null"`
BoundarySlot uint64 `gorm:"index;not null"`
}
RewardPoolInput captures per-pool inputs needed by reward calculation.
func (RewardPoolInput) TableName ¶ added in v0.49.0
func (RewardPoolInput) TableName() string
type RewardSnapshot ¶ added in v0.49.0
type RewardSnapshot struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"uniqueIndex:idx_reward_snapshot_epoch_type,priority:1;not null"`
SnapshotType string `gorm:"type:varchar(4);uniqueIndex:idx_reward_snapshot_epoch_type,priority:2;not null"`
TotalActiveStake types.Uint64 `gorm:"not null"`
TotalPoolCount uint64 `gorm:"not null"`
TotalDelegators uint64 `gorm:"not null"`
CapturedSlot uint64 `gorm:"index;not null"`
BoundarySlot uint64 `gorm:"index;not null"`
EpochNonce []byte `gorm:"size:32"`
ProtocolVersion uint `gorm:"not null"`
}
RewardSnapshot captures reward-calculation snapshot metadata for an epoch.
func (RewardSnapshot) TableName ¶ added in v0.49.0
func (RewardSnapshot) TableName() string
type Script ¶
type Script struct {
Hash []byte `gorm:"index;unique;size:28"`
Content []byte
ID uint `gorm:"primaryKey"`
CreatedSlot uint64
Type uint8 `gorm:"index"`
}
Script represents the content of a script, indexed by its hash This avoids storing duplicate script data when the same script appears in multiple transactions
type StakeCredentialRef ¶ added in v0.55.0
func NewStakeCredentialRef ¶ added in v0.55.0
func NewStakeCredentialRef(tag uint8, key []byte) StakeCredentialRef
func (StakeCredentialRef) MapKey ¶ added in v0.55.0
func (r StakeCredentialRef) MapKey() string
type StakeDelegation ¶
type StakeDelegation struct {
StakingKey []byte `gorm:"index:idx_stake_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_delegation_credential,priority:1;not null;default:0"`
PoolKeyHash []byte `gorm:"index;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
}
func (StakeDelegation) TableName ¶
func (StakeDelegation) TableName() string
type StakeDeregistration ¶
type StakeDeregistration struct {
StakingKey []byte `gorm:"index:idx_stake_deregistration_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_deregistration_credential,priority:1;not null;default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
}
func (StakeDeregistration) TableName ¶
func (StakeDeregistration) TableName() string
type StakeRegistration ¶
type StakeRegistration struct {
StakingKey []byte `gorm:"index:idx_stake_registration_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_registration_credential,priority:1;not null;default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (StakeRegistration) TableName ¶
func (StakeRegistration) TableName() string
type StakeRegistrationDelegation ¶
type StakeRegistrationDelegation struct {
StakingKey []byte `gorm:"index:idx_stake_registration_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_registration_delegation_credential,priority:1;not null;default:0"`
PoolKeyHash []byte `gorm:"index;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (StakeRegistrationDelegation) TableName ¶
func (StakeRegistrationDelegation) TableName() string
type StakeVoteDelegation ¶
type StakeVoteDelegation struct {
StakingKey []byte `gorm:"index:idx_stake_vote_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_vote_delegation_credential,priority:1;not null;default:0"`
PoolKeyHash []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
DrepType uint64 `gorm:"default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
}
func (StakeVoteDelegation) TableName ¶
func (StakeVoteDelegation) TableName() string
type StakeVoteRegistrationDelegation ¶
type StakeVoteRegistrationDelegation struct {
StakingKey []byte `gorm:"index:idx_stake_vote_registration_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_stake_vote_registration_delegation_credential,priority:1;not null;default:0"`
PoolKeyHash []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
DrepType uint64 `gorm:"default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (StakeVoteRegistrationDelegation) TableName ¶
func (StakeVoteRegistrationDelegation) TableName() string
type SyncState ¶ added in v0.22.0
type SyncState struct {
Key string `gorm:"column:sync_key;primaryKey;size:255"`
Value string `gorm:"type:text;not null"`
}
SyncState stores ephemeral key-value pairs used during one-time sync/load operations. Cleaned up after completion.
type Transaction ¶
type Transaction struct {
// CollateralReturn uses a separate FK (CollateralReturnForTxID) to distinguish
// from regular Outputs which use TransactionID. This allows GORM to load each
// association correctly without ambiguity.
CollateralReturn *Utxo `gorm:"foreignKey:CollateralReturnForTxID;references:ID;constraint:OnDelete:CASCADE"`
PlutusData []PlutusData `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
Certificates []Certificate `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
Outputs []Utxo `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
Hash []byte `gorm:"uniqueIndex;size:32"`
Collateral []Utxo `gorm:"foreignKey:CollateralByTxId;references:Hash"`
BlockHash []byte `gorm:"index;size:32"`
KeyWitnesses []KeyWitness `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
WitnessScripts []WitnessScripts `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
Inputs []Utxo `gorm:"foreignKey:SpentAtTxId;references:Hash"`
Redeemers []Redeemer `gorm:"foreignKey:TransactionID;references:ID;constraint:OnDelete:CASCADE"`
ReferenceInputs []Utxo `gorm:"foreignKey:ReferencedByTxId;references:Hash"`
Metadata []byte
Slot uint64 `gorm:"index"`
Type int
ID uint `gorm:"primaryKey"`
Fee types.Uint64
TTL types.Uint64
BlockIndex uint32
Valid bool
}
Transaction represents a transaction record
func (Transaction) TableName ¶
func (Transaction) TableName() string
type TransactionMetadataLabel ¶ added in v0.28.0
type TransactionMetadataLabel struct {
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"uniqueIndex:idx_tx_metadata_label_tx_label"`
Label types.Uint64 `gorm:"index;uniqueIndex:idx_tx_metadata_label_tx_label"`
Slot uint64 `gorm:"index"`
CborValue []byte
JsonValue string `gorm:"type:text"`
}
TransactionMetadataLabel stores per-label transaction metadata values for efficient label-based querying.
func (TransactionMetadataLabel) TableName ¶ added in v0.28.0
func (TransactionMetadataLabel) TableName() string
type UpdateDrep ¶
type UpdateDrep struct {
AnchorURL string `gorm:"column:anchor_url;size:128"`
Credential []byte `gorm:"index:idx_update_drep_credential,priority:2;size:28"`
AnchorHash []byte
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
CredentialTag uint8 `gorm:"index:idx_update_drep_credential,priority:1;not null;default:0"`
AddedSlot uint64 `gorm:"index"`
}
func (UpdateDrep) TableName ¶
func (UpdateDrep) TableName() string
type Utxo ¶
type Utxo struct {
TransactionID *uint `gorm:"index"`
CollateralReturnForTxID *uint `gorm:"uniqueIndex"` // Unique: a transaction has at most one collateral return output
TxId []byte `gorm:"uniqueIndex:tx_id_output_idx;size:32"`
PaymentKey []byte `gorm:"index;size:28"`
StakingKey []byte `gorm:"index;size:28;index:idx_utxo_deleted_staking_amount,priority:3;index:idx_utxo_staking_deleted_amount,priority:2"`
CredentialTag uint8 `gorm:"not null;default:0;index:idx_utxo_deleted_staking_amount,priority:2;index:idx_utxo_staking_deleted_amount,priority:1"`
Assets []Asset `gorm:"foreignKey:UtxoID;constraint:OnDelete:CASCADE"`
Cbor []byte `gorm:"-"` // This is here for convenience but not represented in the metadata DB
DatumHash []byte `gorm:"size:32"` // Optional datum hash (32 bytes)
Datum []byte `gorm:"-"` // Inline datum CBOR, not stored in metadata DB
ScriptRef []byte `gorm:"-"` // Reference script bytes, not stored in metadata DB
// SpentAtTxId, ReferencedByTxId, and CollateralByTxId are nullable FKs to
// transaction(hash); they are unset until a UTxO is spent/referenced.
// They use types.NullableHash so an empty value serializes to SQL NULL
// (not an empty blob), which is required for the FK to be skipped — see
// the type docs for the FOREIGN KEY constraint failed (787) issue.
SpentAtTxId types.NullableHash `gorm:"index;size:32"`
ReferencedByTxId types.NullableHash `gorm:"index;size:32"`
CollateralByTxId types.NullableHash `gorm:"index;size:32"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DeletedSlot uint64 `` /* 153-byte string literal not displayed */
Amount types.Uint64 `` /* 153-byte string literal not displayed */
OutputIdx uint32 `gorm:"uniqueIndex:tx_id_output_idx"`
// PaymentScript is true when the output's payment credential is a
// script hash (as opposed to a key hash). It is derived from the
// address type at index time and used to compute the network's
// script-locked supply (see GetScriptLockedSupply). The composite
// index (deleted_slot, payment_script, amount) lets the supply sum
// scan only live script UTxOs.
PaymentScript bool `gorm:"index:idx_utxo_deleted_payment_script,priority:2"`
}
Utxo represents an unspent transaction output
type UtxoId ¶ added in v0.19.0
UtxoId uniquely identifies a UTxO by transaction hash and output index.
type UtxoOrderingCursor ¶ added in v0.32.0
UtxoOrderingCursor is the keyset position for SearchUtxos.
Text form (non-empty): slot:block_index:output_idx. GetUtxosByAddressWithOrdering uses the producing transaction position for ordering.
type UtxoWithOrdering ¶ added in v0.27.5
type UtxoWithOrdering struct {
Utxo
TxSlot uint64 `gorm:"column:tx_slot"`
TxBlockIndex uint32 `gorm:"column:tx_block_index"`
}
UtxoWithOrdering includes UTxO with transaction ordering metadata
type UtxoWithOrderingQuery ¶ added in v0.32.0
type UtxoWithOrderingQuery struct {
MatchAllAddresses bool
Addresses []ledger.Address
After *UtxoOrderingCursor
Limit int
FilterByAsset bool
AssetPolicyID []byte
AssetName []byte
}
UtxoWithOrderingQuery drives GetUtxosByAddressWithOrdering (single MetadataStore entry).
Address matching (exactly one of these applies):
- MatchAllAddresses true: do not filter by payment/stake keys (all live UTxOs, subject to asset filter if set). SearchUtxos sets this when the predicate is nil or is asset-only (no address pattern).
- MatchAllAddresses false and len(Addresses) == 0: match no rows (caller uses this when a predicate was given but no Cardano address parts could be decoded).
- MatchAllAddresses false and len(Addresses) > 0: match UTxOs that satisfy ANY branch (OR): exact / payment-only / stake-only per address, same rules as legacy addressWhereClause.
After + Limit: keyset pagination; Limit <= 0 means no SQL LIMIT. SearchUtxos sets Limit to effective page size + 1.
FilterByAsset: when true, AssetPolicyID is required; AssetName nil matches any name under the policy (same semantics as GetUtxosByAssets).
type VoteDelegation ¶
type VoteDelegation struct {
StakingKey []byte `gorm:"index:idx_vote_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_vote_delegation_credential,priority:1;not null;default:0"`
Drep []byte `gorm:"index;size:28"`
DrepType uint64 `gorm:"default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
}
func (VoteDelegation) TableName ¶
func (VoteDelegation) TableName() string
type VoteRegistrationDelegation ¶
type VoteRegistrationDelegation struct {
StakingKey []byte `gorm:"index:idx_vote_registration_delegation_credential,priority:2;size:28"`
CredentialTag uint8 `gorm:"index:idx_vote_registration_delegation_credential,priority:1;not null;default:0"`
Drep []byte `gorm:"index;size:28"`
DrepType uint64 `gorm:"default:0"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (VoteRegistrationDelegation) TableName ¶
func (VoteRegistrationDelegation) TableName() string
type WitnessScripts ¶
type WitnessScripts struct {
ScriptHash []byte `gorm:"index;size:28"`
ID uint `gorm:"primaryKey"`
TransactionID uint `gorm:"index"`
Type uint8 `gorm:"index"`
}
WitnessScripts represents a reference to a script in the witness set Type corresponds to ScriptRefType constants from gouroboros/ledger/common: 0=NativeScript (ScriptRefTypeNativeScript) 1=PlutusV1 (ScriptRefTypePlutusV1) 2=PlutusV2 (ScriptRefTypePlutusV2) 3=PlutusV3 (ScriptRefTypePlutusV3)
To avoid storing duplicate script data for the same script used in multiple transactions, we store only the script hash here. The actual script content is stored separately in Script table, indexed by hash.
func (WitnessScripts) TableName ¶
func (WitnessScripts) TableName() string
Source Files
¶
- account.go
- account_history.go
- address_transaction.go
- asset.go
- auth_committee_hot.go
- backfill_checkpoint.go
- block.go
- block_nonce.go
- certs.go
- committee_member.go
- datum.go
- drep.go
- epoch.go
- governance.go
- midnight.go
- mir.go
- models.go
- network_donation.go
- network_state.go
- offchain_metadata.go
- pool.go
- pparams.go
- redeemer.go
- reward_state.go
- script.go
- stake_snapshot.go
- tip.go
- transaction.go
- transaction_metadata_label.go
- utxo.go
- utxoid.go
- witness.go
- witness_script.go