models

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const (
	VoteNo      = 0
	VoteYes     = 1
	VoteAbstain = 2
)

Vote constants represent the vote choice on a governance proposal.

View Source
const (
	ImportPhaseUTxO      = "utxo"
	ImportPhaseCertState = "certstate"
	ImportPhaseSnapshots = "snapshots"
	ImportPhasePParams   = "pparams"
	ImportPhaseGovState  = "gov_state"
	ImportPhaseTip       = "tip"
)

Import phases in execution order.

View Source
const (
	// KeyWitnessTypeVkey represents a Vkey witness
	KeyWitnessTypeVkey uint8 = 0
	// KeyWitnessTypeBootstrap represents a Bootstrap witness
	KeyWitnessTypeBootstrap uint8 = 1
)

Variables

View Source
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",
	)
)
View Source
var ErrAccountNotFound = errors.New("account not found")
View Source
var ErrBlockNotFound = errors.New("block not found")
View Source
var ErrCommitteeMemberNotFound = errors.New("committee member not found")
View Source
var ErrGovernanceProposalNotFound = errors.New("governance proposal not found")
View Source
var ErrPoolNotFound = errors.New("pool not found")

ImportPhaseOrder defines the sequential order of import phases.

MigrateModels contains a list of model objects that should have DB migrations applied

Functions

func DedupePoolStakeSnapshots added in v0.22.0

func DedupePoolStakeSnapshots(db *gorm.DB, logger *slog.Logger) error

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 IsPhaseCompleted added in v0.22.0

func IsPhaseCompleted(checkpointPhase, queryPhase string) bool

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).

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"`
	Reward        types.Uint64
	// DrepType is the CBOR-encoded DRep delegation type:
	//   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"`
	Active   bool   `gorm:"default:true"`
}

func (*Account) String

func (a *Account) String() (string, error)

String returns the bech32-encoded representation of the Account's StakingKey with the "stake" human-readable part. Returns an error if the StakingKey is empty or if encoding fails.

func (*Account) TableName

func (a *Account) TableName() string

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;size:28"`
	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;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.

func (Asset) TableName

func (Asset) TableName() string

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 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 Block struct {
	Hash     []byte `gorm:"index:hash_slot;size:32"`
	PrevHash []byte
	Cbor     []byte
	ID       uint64 `gorm:"primaryKey"`
	Slot     uint64 `gorm:"index:hash_slot"`
	Number   uint64
	Type     uint
}

func (Block) Decode

func (b Block) Decode() (ledger.Block, error)

func (Block) TableName

func (Block) TableName() string

TableName overrides default table name

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 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 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 Datum struct {
	Hash      []byte `gorm:"index;not null;unique;size:32"`
	RawDatum  []byte `gorm:"not null"`
	ID        uint   `gorm:"primarykey"`
	AddedSlot uint64 `gorm:"index;not null"`
}

func (Datum) TableName

func (Datum) TableName() string

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 Drep struct {
	AnchorURL  string `gorm:"column:anchor_url;size:128"`
	Credential []byte `gorm:"uniqueIndex;size:28"`
	AnchorHash []byte
	ID         uint   `gorm:"primarykey"`
	AddedSlot  uint64 `gorm:"index"`
	// 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"`
}

func (*Drep) TableName

func (d *Drep) TableName() string

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
}

func (Epoch) TableName

func (Epoch) TableName() string

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:"size:32"`
	ParentActionIdx *uint32
	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)
	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
	VoterCredential []byte  `gorm:"index:idx_vote_voter,priority:2;uniqueIndex:idx_vote_unique,priority:3;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"`
	VoteUpdatedSlot *uint64 `gorm:"index"` // Slot when vote was last changed (for rollback safety)
	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 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

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 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 PParams struct {
	Cbor      []byte
	ID        uint   `gorm:"primarykey"`
	AddedSlot uint64 `gorm:"index"`
	Epoch     uint64
	EraId     uint
}

func (PParams) TableName

func (PParams) TableName() string

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

func (*Pool) TableName

func (p *Pool) 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
	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 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"`
}

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

func (Redeemer) TableName

func (Redeemer) TableName() string

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 `gorm:"column:anchor_url;size:128"`
	DrepCredential []byte `gorm:"uniqueIndex:idx_drep_reg_cred_slot;size:28"`
	AnchorHash     []byte
	CertificateID  uint   `gorm:"index"`
	ID             uint   `gorm:"primarykey"`
	AddedSlot      uint64 `gorm:"uniqueIndex:idx_drep_reg_cred_slot"`
	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 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

func (Script) TableName

func (Script) TableName() string

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

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.

func (SyncState) TableName added in v0.22.0

func (SyncState) TableName() string

TableName returns the table name for SyncState.

type Tip

type Tip struct {
	Hash        []byte
	ID          uint `gorm:"primarykey"`
	Slot        uint64
	BlockNumber uint64
}

func (Tip) TableName

func (Tip) 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 `gorm:"column:anchor_url;size:128"`
	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
	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             []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

func UtxoLedgerToModel

func UtxoLedgerToModel(
	utxo ledger.Utxo,
	slot uint64,
) Utxo

func (*Utxo) Decode

func (u *Utxo) Decode() (ledger.TransactionOutput, error)

func (*Utxo) TableName

func (u *Utxo) TableName() string

type UtxoId added in v0.19.0

type UtxoId struct {
	Hash []byte
	Idx  uint32
}

UtxoId uniquely identifies a UTxO by transaction hash and output index.

type UtxoSlot

type UtxoSlot struct {
	Utxo ledger.Utxo
	Slot uint64
}

UtxoSlot allows providing a slot number with a ledger.Utxo object

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

Jump to

Keyboard shortcuts

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