Documentation
¶
Index ¶
- Constants
- Variables
- type Account
- type Asset
- type AuthCommitteeHot
- type Block
- type BlockNonce
- type Certificate
- type Datum
- type Deregistration
- type DeregistrationDrep
- type Drep
- type Epoch
- type EpochSummary
- type KeyWitness
- type MoveInstantaneousRewards
- type MoveInstantaneousRewardsReward
- type PParamUpdate
- type PParams
- type PlutusData
- type Pool
- type PoolRegistration
- type PoolRegistrationOwner
- type PoolRegistrationRelay
- type PoolRetirement
- type PoolStakeSnapshot
- type Redeemer
- type Registration
- type RegistrationDrep
- type ResignCommitteeCold
- type Script
- type StakeDelegation
- type StakeDeregistration
- type StakeRegistration
- type StakeRegistrationDelegation
- type StakeVoteDelegation
- type StakeVoteRegistrationDelegation
- type Tip
- type Transaction
- type UpdateDrep
- type Utxo
- type UtxoId
- type UtxoSlot
- type VoteDelegation
- type VoteRegistrationDelegation
- type WitnessScripts
Constants ¶
const ( // KeyWitnessTypeVkey represents a Vkey witness KeyWitnessTypeVkey uint8 = 0 // KeyWitnessTypeBootstrap represents a Bootstrap witness KeyWitnessTypeBootstrap uint8 = 1 )
Variables ¶
var ErrAccountNotFound = errors.New("account not found")
var ErrBlockNotFound = errors.New("block not found")
var ErrDrepNotFound = errors.New("drep not found")
var ErrPoolNotFound = errors.New("pool not found")
var MigrateModels = []any{ &Account{}, &Asset{}, &AuthCommitteeHot{}, &BlockNonce{}, &Certificate{}, &Datum{}, &Deregistration{}, &DeregistrationDrep{}, &Drep{}, &Epoch{}, &EpochSummary{}, &KeyWitness{}, &MoveInstantaneousRewards{}, &MoveInstantaneousRewardsReward{}, &Pool{}, &PoolRegistration{}, &PoolRegistrationOwner{}, &PoolRegistrationRelay{}, &PoolRetirement{}, &PoolStakeSnapshot{}, &PParams{}, &PParamUpdate{}, &PlutusData{}, &Registration{}, &RegistrationDrep{}, &Redeemer{}, &ResignCommitteeCold{}, &Script{}, &StakeDelegation{}, &StakeDeregistration{}, &StakeRegistration{}, &StakeRegistrationDelegation{}, &StakeVoteDelegation{}, &StakeVoteRegistrationDelegation{}, &Tip{}, &Transaction{}, &UpdateDrep{}, &Utxo{}, &VoteDelegation{}, &VoteRegistrationDelegation{}, &WitnessScripts{}, }
MigrateModels contains a list of model objects that should have DB migrations applied
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
StakingKey []byte `gorm:"uniqueIndex;size:28"`
Pool []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
CertificateID uint `gorm:"index"`
Active bool `gorm:"default:true"`
}
type Asset ¶
type Asset struct {
Name []byte `gorm:"index;size:32"`
NameHex []byte `gorm:"index;size:64"`
PolicyId []byte `gorm:"index;size:28"`
Fingerprint []byte `gorm:"index;size:48"`
ID uint `gorm:"primaryKey"`
UtxoID uint `gorm:"index"`
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"`
HostCredential []byte `gorm:"index;size:28"`
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
}
func (AuthCommitteeHot) TableName ¶
func (AuthCommitteeHot) TableName() string
type Block ¶
type BlockNonce ¶
type BlockNonce struct {
Hash []byte `gorm:"index:hash_slot;size:32"`
Nonce []byte
ID uint `gorm:"primarykey"`
Slot uint64 `gorm:"index: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 Datum ¶
type Deregistration ¶
type Deregistration struct {
StakingKey []byte `gorm:"index;size:28"`
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;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (DeregistrationDrep) TableName ¶
func (DeregistrationDrep) TableName() string
type Drep ¶
type Epoch ¶
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 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 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"`
}
func (MoveInstantaneousRewards) TableName ¶
func (MoveInstantaneousRewards) TableName() string
type MoveInstantaneousRewardsReward ¶
type MoveInstantaneousRewardsReward struct {
Credential []byte
Amount types.Uint64
ID uint `gorm:"primarykey"`
MIRID uint `gorm:"index"`
}
func (MoveInstantaneousRewardsReward) TableName ¶
func (MoveInstantaneousRewardsReward) 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
// 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 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
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:"index"`
AddedSlot uint64 `gorm:"index"`
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 PoolStakeSnapshot ¶ added in v0.21.0
type PoolStakeSnapshot struct {
ID uint `gorm:"primarykey"`
Epoch uint64 `gorm:"index:idx_pool_stake_epoch_pool,priority:1;not null"`
SnapshotType string `gorm:"type:varchar(4);index:idx_pool_stake_epoch_pool,priority:2;not null"` // "mark", "set", "go"
PoolKeyHash []byte `gorm:"index:idx_pool_stake_epoch_pool,priority:3;size:28"`
TotalStake types.Uint64 `gorm:"not null"`
DelegatorCount uint64 `gorm:"not null"`
CapturedSlot uint64 `gorm:"not null"`
}
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;size:28"`
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
DrepCredential []byte `gorm:"index;size:28"`
AnchorHash []byte
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (RegistrationDrep) TableName ¶
func (RegistrationDrep) TableName() string
type ResignCommitteeCold ¶
type ResignCommitteeCold struct {
AnchorUrl string
ColdCredential []byte `gorm:"index;size:28"`
AnchorHash []byte
ID uint `gorm:"primarykey"`
CertificateID uint `gorm:"index"`
AddedSlot uint64 `gorm:"index"`
}
func (ResignCommitteeCold) TableName ¶
func (ResignCommitteeCold) 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 StakeDelegation ¶
type StakeDelegation struct {
StakingKey []byte `gorm:"index;size:28"`
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;size:28"`
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;size:28"`
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;size:28"`
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;size:28"`
PoolKeyHash []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
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;size:28"`
PoolKeyHash []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DepositAmount types.Uint64
}
func (StakeVoteRegistrationDelegation) TableName ¶
func (StakeVoteRegistrationDelegation) TableName() string
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 UpdateDrep ¶
type UpdateDrep struct {
AnchorUrl string
Credential []byte `gorm:"index;size:28"`
AnchorHash []byte
CertificateID uint `gorm:"index"`
ID uint `gorm:"primarykey"`
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"`
Assets []Asset `gorm:"foreignKey:UtxoID;constraint:OnDelete:CASCADE"`
Cbor []byte `gorm:"-"` // This is here for convenience but not represented in the metadata DB
SpentAtTxId []byte `gorm:"index;size:32"`
ReferencedByTxId []byte `gorm:"index;size:32"`
CollateralByTxId []byte `gorm:"index;size:32"`
ID uint `gorm:"primarykey"`
AddedSlot uint64 `gorm:"index"`
DeletedSlot uint64 `gorm:"index"`
Amount types.Uint64 `gorm:"index"`
OutputIdx uint32 `gorm:"uniqueIndex:tx_id_output_idx"`
}
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 VoteDelegation ¶
type VoteDelegation struct {
StakingKey []byte `gorm:"index;size:28"`
Drep []byte `gorm:"index;size:28"`
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;size:28"`
Drep []byte `gorm:"index;size:28"`
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