stakequery

package
v0.67.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EffectivePoolRegistrationsForEpoch added in v0.65.0

func EffectivePoolRegistrationsForEpoch(
	db *gorm.DB,
	pkhs [][]byte,
	epochStartSlot uint64,
	endedEpoch uint64,
	snapshotSlot uint64,
) ([]models.PoolRegistration, error)

EffectivePoolRegistrationsForEpoch returns, per pool, the registration certificate whose parameters were in the ledger's pool-params map during the ended epoch spanning [epochStartSlot, snapshotSlot] — the params cardano-ledger's SNAP rule snapshots at the boundary ending that epoch.

A re-registration by an already-registered pool is a future-params update: it promotes at the NEXT boundary (POOLREAP runs after SNAP), so a cert the pool submitted during the ended epoch must not be used. A fresh registration (pool absent from the params map: brand new, or registering again after an executed retirement) takes effect immediately, so for those pools the EARLIEST cert inside the epoch applies.

Selection per pool: rank all registration certs plus executed-retirement candidates (retirement certs scheduled for an epoch at or before the ended epoch) that precede epochStartSlot by chain position. If the latest such event is a registration, it is the effective cert — any earlier retirement was either cancelled or followed by that fresh registration. If it is a retirement (or no event exists), the pool entered the params map during the ended epoch and its earliest in-epoch cert applies.

func GetPoolOwnerStakeAtSlot added in v0.65.0

func GetPoolOwnerStakeAtSlot(
	db *gorm.DB,
	ownerKeys [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
) (map[string]uint64, error)

GetPoolOwnerStakeAtSlot returns stake only for the requested key-hash owner credentials, and only under the pool to which each credential was delegated at slot. The result cardinality is bounded by the owner set, not by all pool delegators.

func GetRewardStakeInputsByPoolsAtSlot added in v0.67.0

func GetRewardStakeInputsByPoolsAtSlot(
	db *gorm.DB,
	poolKeyHashes [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
) ([]*models.RewardStakeInput, error)

GetRewardStakeInputsByPoolsAtSlot returns positive per-credential delegated stake for the requested pools reconstructed at slot, from the same active_delegator_stake CTE that GetStakeByPoolsAtSlot aggregates for leader-election pool totals. Sourcing both halves of the epoch-boundary snapshot from one CTE makes the reward-basis inputs agree with the leader-election stake by construction: identical credential membership, identical slot-accurate stake values, and the identical CIP-0163 historical expiry filter (expiration reconstructed at slot, not read from the mutable live account.expiration_epoch column). It is used only when the delegator-inactivity gate is active (expiryEpoch > 0); the gate-off reward path stays on the live aggregate (StakeInputsForPools) to remain byte-identical to the pre-CIP query.

func GetStakeByPoolsAtSlot

func GetStakeByPoolsAtSlot(
	db *gorm.DB,
	poolKeyHashes [][]byte,
	slot uint64,
	expiryEpoch uint64,
	inactivityPeriod uint64,
) (map[string]uint64, map[string]uint64, error)

GetStakeByPoolsAtSlot returns delegated stake and delegator counts at a historical slot. It uses certificate history to find each credential's latest stake delegation and registration state, and account rows as synthetic state for imported/bootstrap data where the certificate history is unavailable.

func PopulatePoolRegistrationOwners added in v0.65.0

func PopulatePoolRegistrationOwners(
	db *gorm.DB,
	registrations []models.PoolRegistration,
) error

PopulatePoolRegistrationOwners loads and attaches the owners for a set of pool registrations. Queries are chunked according to the backend's bind variable capacity.

Types

This section is empty.

Jump to

Keyboard shortcuts

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