localstatequery

package
v0.188.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 6

README

LocalStateQuery Protocol

The LocalStateQuery protocol queries the local node's ledger state at specific chain points. It is used for wallet queries, stake information, protocol parameters, and other state queries.

Protocol Identifiers

Property Value
Protocol Name local-state-query
Protocol ID 7
Mode Node-to-Client

State Machine

┌──────┐     Acquire/AcquireVolatileTip/     ┌───────────┐
│ Idle │     AcquireImmutableTip             │ Acquiring │
└──┬───┘ ─────────────────────────────────►  └─────┬─────┘
   │                                               │
   │ Done                             Failure      │ Acquired
   │                                    │          │
   ▼                                    ▼          ▼
┌──────┐                             ┌──────┐  ┌──────────┐
│ Done │◄────────────────────────────│ Idle │◄─│ Acquired │
└──────┘                             └──────┘  └────┬─────┘
                                                    │
                        ┌───────────────────────────┤
                        │                           │
           Query        │    Reacquire/             │ Release
                        │    ReacquireVolatileTip/  │
                        │    ReacquireImmutableTip  │
                        ▼                           │
                 ┌──────────┐                       │
                 │ Querying │                       │
                 └────┬─────┘                       │
                      │                             │
                      │ Result                      │
                      ▼                             ▼
                 ┌──────────┐                  ┌──────┐
                 │ Acquired │                  │ Idle │
                 └──────────┘                  └──────┘

States

State ID Agency Description
Idle 1 Client No state acquired
Acquiring 2 Server Processing state acquisition
Acquired 3 Client State acquired, ready for queries
Querying 4 Server Processing query
Done 5 None Terminal state

Messages

Message Type ID Direction Description
Acquire 0 Client → Server Acquire state at specific point
Acquired 1 Server → Client State successfully acquired
Failure 2 Server → Client State acquisition failed
Query 3 Client → Server Execute query on acquired state
Result 4 Server → Client Query result
Release 5 Client → Server Release acquired state
Reacquire 6 Client → Server Reacquire at different point
Done 7 Client → Server Terminate protocol
AcquireVolatileTip 8 Client → Server Acquire state at volatile tip
ReacquireVolatileTip 9 Client → Server Reacquire at volatile tip
AcquireImmutableTip 10 Client → Server Acquire state at immutable tip
ReacquireImmutableTip 11 Client → Server Reacquire at immutable tip

State Transitions

From Idle (Client Agency)
Message New State
Acquire Acquiring
AcquireVolatileTip Acquiring
AcquireImmutableTip Acquiring
Done Done
From Acquiring (Server Agency)
Message New State
Failure Idle
Acquired Acquired
From Acquired (Client Agency)
Message New State
Query Querying
Reacquire Acquiring
ReacquireVolatileTip Acquiring
ReacquireImmutableTip Acquiring
Release Idle
From Querying (Server Agency)
Message New State
Result Acquired

Timeouts

Timeout Default Description
Acquire Timeout 5 seconds Time to acquire state
Query Timeout 180 seconds Time to execute query

Acquire Targets

Target Description
Specific Point Acquire state at a specific slot/hash
Volatile Tip Acquire state at the current volatile tip
Immutable Tip Acquire state at the current immutable tip

Configuration Options

localstatequery.NewConfig(
    localstatequery.WithAcquireFunc(acquireCallback),
    localstatequery.WithQueryFunc(queryCallback),
    localstatequery.WithReleaseFunc(releaseCallback),
    localstatequery.WithAcquireTimeout(5 * time.Second),
    localstatequery.WithQueryTimeout(180 * time.Second),
)

Usage Example

// Acquire state at tip
client.AcquireVolatileTip()

// Wait for Acquired message

// Query UTxOs for an address
result, err := client.Query(utxosByAddressQuery)

// Release state when done
client.Release()

Common Queries

  • GetCurrentPParams: Protocol parameters
  • GetStakeDistribution: Stake pool distribution
  • GetUTxOByAddress: UTxOs at specific addresses
  • GetUTxOByTxIn: UTxOs by transaction inputs
  • GetEpochNo: Current epoch number
  • GetGenesisConfig: Genesis configuration
  • GetRewardInfoPools: Pool reward information
  • GetRewardProvenance: Reward calculation details
  • GetStakePools: Registered stake pools
  • GetStakePoolParams: Stake pool parameters

Notes

  • State must be acquired before queries can be executed
  • Multiple queries can be executed on the same acquired state
  • The acquired state is a snapshot; chain may advance during queries
  • Use Reacquire to get a fresh state snapshot
  • Release state when done to free server resources

Documentation

Overview

Package localstatequery implements the Ouroboros local state query mini-protocol.

AI Navigation Guide

Key files in this package:

  • localstatequery.go: Protocol definition, state machine, constants
  • queries.go: Query type definitions and CBOR encoding (start here for query work)
  • client.go: Client-side query execution methods
  • server.go: Server-side query handling
  • messages.go: Protocol message types

State Machine

The protocol follows this state flow:

Idle -> Acquiring -> Acquired -> Querying -> Acquired -> ...
                 \-> Idle (on release)

Known Incomplete Areas

Several query types have partial implementations (see TODOs with issue references):

  • #858: Protocol parameters need additional fields
  • #860: Some query result types incomplete
  • #863-867: Various query implementations pending

Common Patterns

Queries are era-polymorphic. Check CurrentEra() before sending era-specific queries. Results decode into era-specific types based on the query type.

Example Usage

client, _ := localstatequery.NewClient(...)
client.Acquire(point)  // Acquire state at a specific chain point
result, _ := client.GetCurrentEra()
client.Release()

Package localstatequery implements the Ouroboros local-state-query protocol

Index

Constants

View Source
const (
	ProtocolName        = "local-state-query"
	ProtocolId   uint16 = 7
)

Protocol identifiers

View Source
const (
	MessageTypeAcquire               = 0
	MessageTypeAcquired              = 1
	MessageTypeFailure               = 2
	MessageTypeQuery                 = 3
	MessageTypeResult                = 4
	MessageTypeRelease               = 5
	MessageTypeReacquire             = 6
	MessageTypeDone                  = 7
	MessageTypeAcquireVolatileTip    = 8
	MessageTypeReacquireVolatileTip  = 9
	MessageTypeAcquireImmutableTip   = 10
	MessageTypeReacquireImmutableTip = 11
)

Message types

View Source
const (
	AcquireFailurePointTooOld     = 0
	AcquireFailurePointNotOnChain = 1
)

Acquire failure reasons

View Source
const (
	QueryTypeBlock        = 0
	QueryTypeSystemStart  = 1
	QueryTypeChainBlockNo = 2
	QueryTypeChainPoint   = 3

	// Block query sub-types
	QueryTypeShelley  = 0
	QueryTypeHardFork = 2

	// Hard fork query sub-types
	QueryTypeHardForkEraHistory = 0
	QueryTypeHardForkCurrentEra = 1

	// Shelley query sub-types
	QueryTypeShelleyLedgerTip                           = 0
	QueryTypeShelleyEpochNo                             = 1
	QueryTypeShelleyNonMyopicMemberRewards              = 2
	QueryTypeShelleyCurrentProtocolParams               = 3
	QueryTypeShelleyProposedProtocolParamsUpdates       = 4
	QueryTypeShelleyStakeDistribution                   = 5
	QueryTypeShelleyUtxoByAddress                       = 6
	QueryTypeShelleyUtxoWhole                           = 7
	QueryTypeShelleyDebugEpochState                     = 8
	QueryTypeShelleyCbor                                = 9
	QueryTypeShelleyFilteredDelegationAndRewardAccounts = 10
	QueryTypeShelleyGenesisConfig                       = 11
	QueryTypeShelleyDebugNewEpochState                  = 12
	QueryTypeShelleyDebugChainDepState                  = 13
	QueryTypeShelleyRewardProvenance                    = 14
	QueryTypeShelleyUtxoByTxin                          = 15
	QueryTypeShelleyStakePools                          = 16
	QueryTypeShelleyStakePoolParams                     = 17
	QueryTypeShelleyRewardInfoPools                     = 18
	QueryTypeShelleyPoolState                           = 19
	QueryTypeShelleyStakeSnapshots                      = 20
	QueryTypeShelleyPoolDistr                           = 21

	// Conway governance queries (v8+)
	QueryTypeShelleyConstitution           = 23
	QueryTypeShelleyGovState               = 24
	QueryTypeShelleyDRepState              = 25
	QueryTypeShelleyDRepStakeDistr         = 26
	QueryTypeShelleyCommitteeMembersState  = 27
	QueryTypeShelleyFilteredVoteDelegatees = 28
	QueryTypeShelleyAccountState           = 29
	QueryTypeShelleySPOStakeDistr          = 30
	QueryTypeShelleyGetProposals           = 31
	QueryTypeShelleyGetRatifyState         = 32

	// GetLedgerPeerSnapshot (Shelley sub-query 34, NtC v19+ / cardano-node 10.7+).
	// The v15+ wire layout includes a peer-kind byte: [34, peerKindTag].
	QueryTypeShelleyGetLedgerPeerSnapshot = 34
)

Query types

Variables

View Source
var ErrAcquireFailurePointNotOnChain = errors.New(
	"acquire failure: point not on chain",
)

ErrAcquireFailurePointNotOnChain indicates a failure to acquire a point due to it not being present on the chain

View Source
var ErrAcquireFailurePointTooOld = errors.New("acquire failure: point too old")

ErrAcquireFailurePointTooOld indicates a failure to acquire a point due to it being too old

View Source
var ErrLedgerPeerSnapshotUnsupportedVersion = errors.New(
	"GetLedgerPeerSnapshot requires node-to-client protocol version 19 or later",
)

ErrLedgerPeerSnapshotUnsupportedVersion indicates that GetLedgerPeerSnapshot was called on a connection whose negotiated node-to-client protocol version is older than the one that introduced the query (NtC v19, cardano-node 10.7).

View Source
var StateMap = protocol.StateMap{
	// contains filtered or unexported fields
}

LocalStateQuery protocol state machine

Functions

func NewMsgFromCbor

func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)

NewMsgFromCbor parses a LocalStateQuery message from CBOR

Types

type AccountState added in v0.183.0

type AccountState struct {
	cbor.StructAsArray
	Treasury int64
	Reserves int64
}

AccountState is the chain's treasury and reserves pots. Both are signed because Coin is an Integer in the ledger (a misconfigured network can drive reserves negative).

type AccountStateResult added in v0.183.0

type AccountStateResult struct {
	cbor.StructAsArray
	State AccountState
}

AccountStateResult is the result of GetAccountState. The account state is wrapped in the single-element result array, so on the wire it is [ [treasury, reserves] ].

type AcquireFunc

type AcquireFunc func(CallbackContext, AcquireTarget, bool) error

Callback function types

type AcquireImmutableTip added in v0.106.0

type AcquireImmutableTip struct{}

type AcquireSpecificPoint added in v0.106.0

type AcquireSpecificPoint struct {
	Point pcommon.Point
}

type AcquireTarget added in v0.106.0

type AcquireTarget interface {
	// contains filtered or unexported methods
}

Acquire target types

type AcquireVolatileTip added in v0.106.0

type AcquireVolatileTip struct{}

type BlockQuery added in v0.106.0

type BlockQuery struct {
	Query any
}

func (*BlockQuery) MarshalCBOR added in v0.106.0

func (q *BlockQuery) MarshalCBOR() ([]byte, error)

func (*BlockQuery) UnmarshalCBOR added in v0.106.0

func (q *BlockQuery) UnmarshalCBOR(data []byte) error

type CallbackContext added in v0.78.0

type CallbackContext struct {
	ConnectionId connection.ConnectionId
	Client       *Client
	Server       *Server
}

Callback context

type ChainBlockNoQuery added in v0.106.0

type ChainBlockNoQuery struct {
	// contains filtered or unexported fields
}

type ChainPointQuery added in v0.106.0

type ChainPointQuery struct {
	// contains filtered or unexported fields
}

type Client

type Client struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

Client implements the LocalStateQuery client

func NewClient

func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client

NewClient returns a new LocalStateQuery client object

func (*Client) Acquire

func (c *Client) Acquire(point *pcommon.Point) error

Acquire starts the acquire process for the specified chain point

func (*Client) AcquireImmutableTip added in v0.106.0

func (c *Client) AcquireImmutableTip() error

func (*Client) AcquireVolatileTip added in v0.106.0

func (c *Client) AcquireVolatileTip() error

func (*Client) DebugChainDepState

func (c *Client) DebugChainDepState() (*DebugChainDepStateResult, error)

func (*Client) DebugEpochState

func (c *Client) DebugEpochState() (*DebugEpochStateResult, error)

func (*Client) DebugNewEpochState

func (c *Client) DebugNewEpochState() (*DebugNewEpochStateResult, error)

func (*Client) GetAccountState added in v0.183.0

func (c *Client) GetAccountState() (*AccountStateResult, error)

func (*Client) GetChainBlockNo

func (c *Client) GetChainBlockNo() (int64, error)

GetChainBlockNo returns the latest block number

func (*Client) GetChainPoint

func (c *Client) GetChainPoint() (*pcommon.Point, error)

GetChainPoint returns the current chain tip

func (*Client) GetCommitteeMembersState added in v0.150.0

func (c *Client) GetCommitteeMembersState(
	coldCreds []lcommon.Credential,
	hotCreds []lcommon.Credential,
	statuses []int,
) (*CommitteeMembersStateResult, error)

GetCommitteeMembersState returns the state of the constitutional committee (CIP-1694).

Use this to inspect committee members and their standing: each member's hot-credential authorization status (not-authorized, authorized, or resigned), its term status (active, expired, or unrecognized), its term expiry epoch, and any change scheduled for the next epoch boundary, along with the committee voting threshold and the current epoch.

The three filters narrow the response: by member cold credentials, by hot credentials, and by member status (see MemberStatus). Pass nil/empty for a filter to leave it unconstrained; passing nil for all three returns every member. The committee uses a hot/cold key setup, so a member is identified by its cold credential and votes with its authorized hot credential.

Response: a CommitteeMembersStateResult mapping each member's cold credential to a CommitteeMemberState, plus the cbor.Rat threshold and epoch.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetConstitution added in v0.150.0

func (c *Client) GetConstitution() (*ConstitutionResult, error)

GetConstitution returns the current on-chain constitution (CIP-1694).

Use this to read the constitution that governance actions are checked against: its metadata anchor (URL and hash of the constitution document) and the optional guardrails script hash that constrains protocol-parameter and treasury-withdrawal actions.

Response: a ConstitutionResult with the anchor and optional guardrails script hash (nil when no guardrails script is set).

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetCurrentEra

func (c *Client) GetCurrentEra() (int, error)

GetCurrentEra returns the current era ID

func (*Client) GetCurrentProtocolParams

func (c *Client) GetCurrentProtocolParams() (lcommon.ProtocolParameters, error)

GetCurrentProtocolParams returns the set of protocol params that are currently in effect

func (*Client) GetDRepStakeDistr added in v0.150.0

func (c *Client) GetDRepStakeDistr(
	dreps []lcommon.Drep,
) (*DRepStakeDistrResult, error)

GetDRepStakeDistr returns the stake distribution across DReps (CIP-1694).

Use this to read the voting power (total delegated stake, in lovelace) of DReps, for example to weigh how a proposal's DRep votes translate into stake. Pass a list of DReps to filter the response, or nil/empty for the full distribution. Note the lcommon.Drep type also covers the predefined Abstain and NoConfidence options, not only credential-backed DReps.

Response: a DRepStakeDistrResult containing the raw CBOR map of DReps to stake amounts. It is returned undecoded because its key encoding is era-specific; decode it with cbor.Decode against an era-appropriate type.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetDRepState added in v0.150.0

func (c *Client) GetDRepState(
	credentials []lcommon.Credential,
) (*DRepStateResult, error)

GetDRepState returns the registration state of delegate representatives (DReps) (CIP-1694).

Use this to inspect registered DReps: when each one's activity period expires, the deposit it locked at registration, and its optional metadata anchor. Pass a list of DRep credentials to filter the response, or nil/empty to return the state of every registered DRep.

Response: a DRepStateResult, a map keyed by each DRep's credential with a DRepStateEntry value (expiry epoch, deposit, optional anchor).

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetEpochNo

func (c *Client) GetEpochNo() (int, error)

GetEpochNo returns the current epoch number

func (*Client) GetEraHistory

func (c *Client) GetEraHistory() ([]EraHistoryResult, error)

GetEraHistory returns the era history

func (*Client) GetFilteredDelegationsAndRewardAccounts

func (c *Client) GetFilteredDelegationsAndRewardAccounts(
	creds []StakeCredential,
) (*FilteredDelegationsAndRewardAccountsResult, error)

func (*Client) GetFilteredVoteDelegatees added in v0.150.0

func (c *Client) GetFilteredVoteDelegatees(
	credentials []lcommon.Credential,
) (*FilteredVoteDelegateesResult, error)

GetFilteredVoteDelegatees returns the DRep that each stake credential has delegated its vote to (CIP-1694).

Use this to look up where stake credentials have delegated their voting rights. Per CIP-1694 a vote-delegation certificate maps a stake credential to a DRep credential, so each result is a single lcommon.Drep; that DRep may be a credential-backed DRep or one of the predefined Abstain or NoConfidence options. Pass a list of stake credentials to filter the response, or nil/empty to return delegations for all credentials.

Response: a FilteredVoteDelegateesResult, a map keyed by stake credential with the delegated lcommon.Drep as the value.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetGenesisConfig

func (c *Client) GetGenesisConfig() (*GenesisConfigResult, error)

func (*Client) GetGovState added in v0.150.0

func (c *Client) GetGovState() (*GovStateResult, error)

GetGovState returns the full governance state (CIP-1694).

Use this as the one-shot snapshot of everything governance-related: the active proposals with their voting state, the constitutional committee, the constitution, the current/previous/scheduled protocol parameters, and the DRep pulsing state. Prefer the narrower queries (Client.GetProposals, Client.GetDRepState, Client.GetCommitteeMembersState) when you only need one piece, as this query returns and decodes considerably more data.

Response: a GovStateResult. Several fields are returned as raw CBOR because their shape is era-specific; the Committee field is a StrictMaybe and can be decoded with GovStateResult.DecodeCommittee.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetLedgerPeerSnapshot added in v0.171.0

func (c *Client) GetLedgerPeerSnapshot(
	peerKind LedgerPeerKind,
) (*LedgerPeerSnapshotResult, error)

GetLedgerPeerSnapshot returns the ledger peer snapshot used by node-to-node peer discovery (introduced at node-to-client protocol version 19 / cardano-node 10.7). The PeerKind argument selects which set of pools the snapshot covers: LedgerPeerKindAll (SingAllLedgerPeers) is what cardano-node uses for its general ledger-peer feed; LedgerPeerKindBig (SingBigLedgerPeers) restricts the response to the high-stake "big" pools used by Genesis diffusion.

The returned LedgerPeerSnapshotResult preserves the snapshot slot (or origin), each pool's accumulated and own stake, and the typed list of relay endpoints (IPv4, IPv6, A-record domain, SRV domain).

Returns ErrLedgerPeerSnapshotUnsupportedVersion if the negotiated node-to-client protocol version does not advertise the query.

func (*Client) GetNonMyopicMemberRewards

func (c *Client) GetNonMyopicMemberRewards(stakes []any) (*NonMyopicMemberRewardsResult, error)

GetNonMyopicMemberRewards returns the non-myopic member rewards for the given stakes stakes should be an array of [tag, stake_amount] pairs where tag is 0 for KeyHash credentials The array must be sorted by stake amount

func (*Client) GetPoolDistr

func (c *Client) GetPoolDistr(poolIds []any) (*PoolDistrResult, error)

func (*Client) GetPoolState

func (c *Client) GetPoolState(poolIds []any) (*PoolStateResult, error)

func (*Client) GetProposals added in v0.155.0

func (c *Client) GetProposals() (*ProposalsResult, error)

GetProposals returns all active governance proposals (CIP-1694).

Use this to enumerate governance actions that are currently open for voting and to inspect their tally. Each entry carries the governance action ID (the creating transaction hash plus the action's index within that transaction), the votes cast so far by the constitutional committee, DReps, and SPOs, the raw proposal procedure, and the epoch window during which the action is live (proposed-in epoch through expires-after epoch).

Response: a ProposalsResult, a slice of GovActionState, one per active proposal.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetProposedProtocolParamsUpdates

func (c *Client) GetProposedProtocolParamsUpdates() (*ProposedProtocolParamsUpdatesResult, error)

GetProposedProtocolParamsUpdates returns the set of proposed protocol params updates

func (*Client) GetRatifyState added in v0.158.0

func (c *Client) GetRatifyState() (*RatifyStateResult, error)

GetRatifyState returns the current governance ratification state (CIP-1694).

Governance actions are checked for ratification on the epoch boundary and enacted on the following boundary. Use this to see the outcome of that process for the current epoch: the enact state (the committee, constitution, protocol parameters, treasury, withdrawals, and previous governance action IDs that will take effect), the actions that were ratified/enacted, the IDs of actions that expired, and a delayed flag indicating that enactment of further actions is held back this epoch (for example behind a hard fork).

Response: a RatifyStateResult with the EnactState, the enacted GovActionState list, the expired lcommon.GovActionId list, and the delayed flag.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetRewardInfoPools

func (c *Client) GetRewardInfoPools() (*RewardInfoPoolsResult, error)

func (*Client) GetRewardProvenance

func (c *Client) GetRewardProvenance() (*RewardProvenanceResult, error)

func (*Client) GetSPOStakeDistr added in v0.150.0

func (c *Client) GetSPOStakeDistr(
	poolIds []ledger.PoolId,
) (*SPOStakeDistrResult, error)

GetSPOStakeDistr returns the stake-pool-operator (SPO) stake distribution used for governance voting (CIP-1694).

Use this to read each pool's governance voting power (the Lovelace delegated to it), for example to weigh how SPO votes on a proposal translate into stake. This is the governance-voting view of pool stake, distinct from the block-production stake distribution returned by Client.GetStakeDistribution. Pass a list of pool IDs to filter the response, or nil/empty for all pools.

Response: an SPOStakeDistrResult mapping each pool ID to its voting power in Lovelace.

Era: requires the Conway era or later. Returns an error if the acquired ledger state is on an earlier era.

func (*Client) GetStakeDistribution

func (c *Client) GetStakeDistribution() (*StakeDistributionResult, error)

GetStakeDistribution returns the stake distribution

func (*Client) GetStakePoolParams

func (c *Client) GetStakePoolParams(
	poolIds []ledger.PoolId,
) (*StakePoolParamsResult, error)

func (*Client) GetStakePools

func (c *Client) GetStakePools() (*StakePoolsResult, error)

func (*Client) GetStakeSnapshots

func (c *Client) GetStakeSnapshots(
	poolIds []any,
) (*StakeSnapshotsResult, error)

func (*Client) GetSystemStart

func (c *Client) GetSystemStart() (*SystemStartResult, error)

GetSystemStart returns the SystemStart value

func (*Client) GetUTxOByAddress

func (c *Client) GetUTxOByAddress(
	addrs []ledger.Address,
) (*UTxOsResult, error)

GetUTxOByAddress returns the UTxOs for a given list of ledger.Address structs

func (*Client) GetUTxOByTxIn

func (c *Client) GetUTxOByTxIn(
	txIns []ledger.TransactionInput,
) (*UTxOByTxInResult, error)

func (*Client) GetUTxOWhole

func (c *Client) GetUTxOWhole() (*UTxOsResult, error)

GetUTxOWhole returns the current UTxO set

func (*Client) Release

func (c *Client) Release() error

Release releases the previously acquired chain point

func (*Client) Start added in v0.73.3

func (c *Client) Start()

type Committee added in v0.157.0

type Committee struct {
	cbor.StructAsArray
	Members   map[StakeCredential]uint64 // Cold credential -> expiry epoch
	Threshold cbor.Rat
}

Committee represents the constitutional committee. Members maps cold credentials to their expiry epoch. Threshold is the voting threshold as a rational number.

type CommitteeMemberState added in v0.150.0

type CommitteeMemberState struct {
	cbor.StructAsArray
	HotCredStatus   HotCredAuthStatusValue
	Status          MemberStatus
	Expiry          *uint64
	NextEpochChange NextEpochChangeValue
}

CommitteeMemberState represents the state of a committee member

type CommitteeMembersStateResult added in v0.150.0

type CommitteeMembersStateResult struct {
	cbor.StructAsArray
	Members   map[StakeCredential]CommitteeMemberState
	Threshold *cbor.Rat
	Epoch     uint64
}

CommitteeMembersStateResult represents the committee members state query result. Contains the committee members, voting threshold, and current epoch

type Config

type Config struct {
	AcquireFunc    AcquireFunc
	QueryFunc      QueryFunc
	ReleaseFunc    ReleaseFunc
	AcquireTimeout time.Duration
	QueryTimeout   time.Duration
}

Config is used to configure the LocalStateQuery protocol instance

func NewConfig

func NewConfig(options ...LocalStateQueryOptionFunc) Config

NewConfig returns a new LocalStateQuery config object with the provided options

type ConstitutionResult added in v0.150.0

type ConstitutionResult struct {
	cbor.StructAsArray
	Anchor     lcommon.GovAnchor
	ScriptHash []byte // Optional guardrails script hash (nil if no guardrails)
}

ConstitutionResult represents the constitution query result. The constitution contains an anchor (URL and hash) and an optional guardrails script hash

type DRepStakeDistrResult added in v0.150.0

type DRepStakeDistrResult cbor.RawMessage

DRepStakeDistrResult represents the DRep stake distribution The result is returned as raw CBOR that maps DReps to stake amounts

type DRepStateEntry added in v0.150.0

type DRepStateEntry struct {
	Expiry     uint64             // Epoch when DRep expires
	Anchor     *lcommon.GovAnchor // Optional metadata anchor
	Deposit    uint64             // Deposit amount
	Delegators []StakeCredential  // Stake credentials delegating to this DRep
}

DRepStateEntry represents the state of a single DRep.

On the wire it is the cardano-node GetDRepState value: a 4-element array

[ expiry, anchor, deposit, delegators ]

where anchor is a StrictMaybe encoded as a list ([] for none, [anchor] for some — not a CBOR null), and delegators is a CBOR set (tag 258) of the stake credentials currently delegating their voting power to this DRep. cardano clients (cardano-cli) decode this exact shape; emitting a 3-element array (no delegators) or a CBOR null anchor makes them fail with a size mismatch.

func (DRepStateEntry) MarshalCBOR added in v0.186.0

func (e DRepStateEntry) MarshalCBOR() ([]byte, error)

func (*DRepStateEntry) UnmarshalCBOR added in v0.186.0

func (e *DRepStateEntry) UnmarshalCBOR(data []byte) error

type DRepStateResult added in v0.150.0

type DRepStateResult map[StakeCredential]DRepStateEntry

DRepStateResult represents the DRep state query result. The result is a map of stake credentials to DRep state entries.

type DebugChainDepStateResult

type DebugChainDepStateResult any

TODO (#865)

type DebugEpochStateResult

type DebugEpochStateResult any

TODO (#863)

type DebugNewEpochStateResult

type DebugNewEpochStateResult any

TODO (#864)

type EnactState added in v0.158.0

type EnactState struct {
	cbor.StructAsArray
	Committee     cbor.RawMessage // Complex committee structure, keep as RawMessage
	Constitution  ConstitutionResult
	CurPParams    cbor.RawMessage // Era-specific protocol params
	PrevPParams   cbor.RawMessage
	Treasury      uint64
	Withdrawals   map[StakeCredential]uint64
	PrevActionIds cbor.RawMessage // Complex map of gov action types to optional action IDs
}

EnactState represents the enactment state within a ratify state result. It contains the current committee, constitution, protocol parameters, treasury, withdrawals, and previous governance action IDs.

type EraHistoryResult

type EraHistoryResult struct {
	cbor.StructAsArray
	Begin  eraHistoryResultBeginEnd
	End    eraHistoryResultBeginEnd
	Params eraHistoryResultParams
}

type FilteredDelegationsAndRewardAccountsResult

type FilteredDelegationsAndRewardAccountsResult struct {
	Delegations map[StakeCredential]ledger.Blake2b224
	Rewards     map[StakeCredential]uint64
}

FilteredDelegationsAndRewardAccountsResult is the result of the GetFilteredDelegationsAndRewardAccounts query. CBOR: array(1)[array(2)[delegation, rewards]] delegation: map[StakeCredential]PoolId, rewards: map[StakeCredential]uint64

func (*FilteredDelegationsAndRewardAccountsResult) UnmarshalCBOR added in v0.161.0

func (r *FilteredDelegationsAndRewardAccountsResult) UnmarshalCBOR(data []byte) error

type FilteredVoteDelegateesResult added in v0.150.0

type FilteredVoteDelegateesResult map[StakeCredential]lcommon.Drep

FilteredVoteDelegateesResult represents the vote delegatees for stake credentials. The result maps stake credentials to their DRep delegations

type GenesisConfigResult

type GenesisConfigResult struct {
	cbor.StructAsArray
	Start             SystemStartResult
	NetworkMagic      int
	NetworkId         uint8
	ActiveSlotsCoeff  []any
	SecurityParam     int
	EpochLength       int
	SlotsPerKESPeriod int
	MaxKESEvolutions  int
	SlotLength        int
	UpdateQuorum      int
	MaxLovelaceSupply int64
	ProtocolParams    GenesisConfigResultProtocolParameters
	// This value contains maps with bytestring keys, which we can't parse yet
	GenDelegs cbor.RawMessage
	Unknown1  any
	Unknown2  any
}

type GenesisConfigResultProtocolParameters added in v0.114.0

type GenesisConfigResultProtocolParameters struct {
	cbor.StructAsArray
	MinFeeA               int
	MinFeeB               int
	MaxBlockBodySize      int
	MaxTxSize             int
	MaxBlockHeaderSize    int
	KeyDeposit            int
	PoolDeposit           int
	EMax                  int
	NOpt                  int
	A0                    []int
	Rho                   []int
	Tau                   []int
	DecentralizationParam []int
	ExtraEntropy          any
	ProtocolVersionMajor  int
	ProtocolVersionMinor  int
	MinUTxOValue          int
	MinPoolCost           int
}

type GovActionState added in v0.155.0

type GovActionState struct {
	cbor.StructAsArray
	Id                lcommon.GovActionId
	CommitteeVotes    map[StakeCredential]lcommon.Vote
	DRepVotes         map[StakeCredential]lcommon.Vote
	SPOVotes          map[ledger.Blake2b224]lcommon.Vote
	ProposalProcedure cbor.RawMessage
	ProposedIn        uint64
	ExpiresAfter      uint64
}

GovActionState represents a governance proposal and its current voting state.

type GovStateResult added in v0.150.0

type GovStateResult struct {
	cbor.StructAsArray
	Proposals        []GovActionState // Governance proposals with voting state
	Committee        cbor.RawMessage  // StrictMaybe Committee
	Constitution     ConstitutionResult
	CurrentPParams   cbor.RawMessage // Era-specific protocol parameters
	PrevPParams      cbor.RawMessage // Previous era protocol parameters
	FuturePParams    cbor.RawMessage // Scheduled parameter changes
	DRepPulsingState cbor.RawMessage // DRep pulsing state
}

GovStateResult represents the full governance state. This includes proposals, committee, constitution, protocol parameters, and DRep pulsing state. The raw messages can be further decoded based on the era.

func (*GovStateResult) DecodeCommittee added in v0.157.0

func (g *GovStateResult) DecodeCommittee() (*Committee, error)

DecodeCommittee decodes the Committee field from its StrictMaybe CBOR encoding. In Cardano, StrictMaybe is encoded as:

  • [0] for SNothing (no committee)
  • [1, data] for SJust (committee present)

Returns nil if the committee is absent (SNothing or empty/nil wrapper).

type HardForkCurrentEraQuery added in v0.106.0

type HardForkCurrentEraQuery struct {
	// contains filtered or unexported fields
}

type HardForkEraHistoryQuery added in v0.106.0

type HardForkEraHistoryQuery struct {
	// contains filtered or unexported fields
}

type HardForkQuery added in v0.106.0

type HardForkQuery struct {
	Query any
}

func (*HardForkQuery) MarshalCBOR added in v0.106.0

func (q *HardForkQuery) MarshalCBOR() ([]byte, error)

func (*HardForkQuery) UnmarshalCBOR added in v0.106.0

func (q *HardForkQuery) UnmarshalCBOR(data []byte) error

type HotCredAuthStatus added in v0.158.0

type HotCredAuthStatus int

HotCredAuthStatus represents the authorization status of a hot credential

const (
	HotCredNotAuthorized HotCredAuthStatus = 0
	HotCredAuthorized    HotCredAuthStatus = 1
	HotCredResigned      HotCredAuthStatus = 2
)

type HotCredAuthStatusValue added in v0.158.0

type HotCredAuthStatusValue struct {
	Status     HotCredAuthStatus
	Credential *lcommon.Credential
	Anchor     *lcommon.GovAnchor
}

HotCredAuthStatusValue represents a tagged union for hot credential authorization status. CBOR encoding: [0] for NotAuthorized, [1, credential] for Authorized, [2, anchor_or_null] for Resigned

func (*HotCredAuthStatusValue) MarshalCBOR added in v0.158.0

func (h *HotCredAuthStatusValue) MarshalCBOR() ([]byte, error)

func (*HotCredAuthStatusValue) UnmarshalCBOR added in v0.158.0

func (h *HotCredAuthStatusValue) UnmarshalCBOR(data []byte) error

type LedgerPeerKind added in v0.171.0

type LedgerPeerKind int

LedgerPeerKind selects which ledger peers the snapshot covers. This corresponds to the Haskell SingLedgerPeersKind GADT in ouroboros-network: SingAllLedgerPeers selects the full set of pools used for general peer discovery, while SingBigLedgerPeers selects only big (i.e. high-stake) pools used by the diffusion layer for Genesis.

const (
	LedgerPeerKindAll LedgerPeerKind = 0 // SingAllLedgerPeers
	LedgerPeerKindBig LedgerPeerKind = 1 // SingBigLedgerPeers
)

type LedgerPeerSnapshotResult added in v0.171.0

type LedgerPeerSnapshotResult struct {
	Version uint64
	Slot    WithOriginSlot
	Pools   []PoolLedgerPeers
}

LedgerPeerSnapshotResult is the typed result of a GetLedgerPeerSnapshot query.

The wire layout is a versioned tagged 2-element array:

[version, [WithOriginSlot, [PoolLedgerPeers ...]]]

Version 0 corresponds to LedgerPeerSnapshotV1 in ouroboros-network. Unknown versions return a decode error so callers do not silently lose fields that a newer node may have added.

func (LedgerPeerSnapshotResult) MarshalCBOR added in v0.171.0

func (l LedgerPeerSnapshotResult) MarshalCBOR() ([]byte, error)

func (*LedgerPeerSnapshotResult) UnmarshalCBOR added in v0.171.0

func (l *LedgerPeerSnapshotResult) UnmarshalCBOR(data []byte) error

type LocalStateQuery

type LocalStateQuery struct {
	Client *Client
	Server *Server
}

LocalStateQuery is a wrapper object that holds the client and server instances

func New

func New(protoOptions protocol.ProtocolOptions, cfg *Config) *LocalStateQuery

New returns a new LocalStateQuery object

type LocalStateQueryOptionFunc

type LocalStateQueryOptionFunc func(*Config)

LocalStateQueryOptionFunc represents a function used to modify the LocalStateQuery protocol config

func WithAcquireFunc

func WithAcquireFunc(acquireFunc AcquireFunc) LocalStateQueryOptionFunc

WithAcquireFunc specifies the Acquire callback function when acting as a server

func WithAcquireTimeout

func WithAcquireTimeout(timeout time.Duration) LocalStateQueryOptionFunc

WithAcquireTimeout specifies the timeout for the Acquire operation when acting as a client

func WithQueryFunc

func WithQueryFunc(queryFunc QueryFunc) LocalStateQueryOptionFunc

WithQueryFunc specifies the Query callback function when acting as a server

func WithQueryTimeout

func WithQueryTimeout(timeout time.Duration) LocalStateQueryOptionFunc

WithQueryTimeout specifies the timeout for the Query operation when acting as a client

func WithReleaseFunc

func WithReleaseFunc(releaseFunc ReleaseFunc) LocalStateQueryOptionFunc

WithReleaseFunc specifies the Release callback function when acting as a server

type MemberStatus added in v0.158.0

type MemberStatus int

MemberStatus represents the status of a committee member

const (
	MemberStatusActive       MemberStatus = 0
	MemberStatusExpired      MemberStatus = 1
	MemberStatusUnrecognized MemberStatus = 2
)

type MsgAcquire

type MsgAcquire struct {
	protocol.MessageBase
	Point pcommon.Point
}

func NewMsgAcquire

func NewMsgAcquire(point pcommon.Point) *MsgAcquire

type MsgAcquireImmutableTip added in v0.106.0

type MsgAcquireImmutableTip struct {
	protocol.MessageBase
}

func NewMsgAcquireImmutableTip added in v0.106.0

func NewMsgAcquireImmutableTip() *MsgAcquireImmutableTip

type MsgAcquireVolatileTip added in v0.106.0

type MsgAcquireVolatileTip struct {
	protocol.MessageBase
}

func NewMsgAcquireVolatileTip added in v0.106.0

func NewMsgAcquireVolatileTip() *MsgAcquireVolatileTip

type MsgAcquired

type MsgAcquired struct {
	protocol.MessageBase
}

func NewMsgAcquired

func NewMsgAcquired() *MsgAcquired

type MsgDone

type MsgDone struct {
	protocol.MessageBase
}

func NewMsgDone

func NewMsgDone() *MsgDone

type MsgFailure

type MsgFailure struct {
	protocol.MessageBase
	Failure uint8
}

func NewMsgFailure

func NewMsgFailure(failure uint8) *MsgFailure

type MsgQuery

type MsgQuery struct {
	protocol.MessageBase
	Query QueryWrapper
}

func NewMsgQuery

func NewMsgQuery(query any) *MsgQuery

type MsgReAcquire

type MsgReAcquire struct {
	protocol.MessageBase
	Point pcommon.Point
}

func NewMsgReAcquire

func NewMsgReAcquire(point pcommon.Point) *MsgReAcquire

type MsgReAcquireImmutableTip added in v0.106.0

type MsgReAcquireImmutableTip struct {
	protocol.MessageBase
}

func NewMsgReAcquireImmutableTip added in v0.106.0

func NewMsgReAcquireImmutableTip() *MsgReAcquireImmutableTip

type MsgReAcquireVolatileTip added in v0.106.0

type MsgReAcquireVolatileTip struct {
	protocol.MessageBase
}

func NewMsgReAcquireVolatileTip added in v0.106.0

func NewMsgReAcquireVolatileTip() *MsgReAcquireVolatileTip

type MsgRelease

type MsgRelease struct {
	protocol.MessageBase
}

func NewMsgRelease

func NewMsgRelease() *MsgRelease

type MsgResult

type MsgResult struct {
	protocol.MessageBase
	Result cbor.RawMessage
}

func NewMsgResult

func NewMsgResult(resultCbor []byte) *MsgResult

type NextEpochChange added in v0.158.0

type NextEpochChange int

NextEpochChange represents the change that will happen at the next epoch

const (
	NextEpochNoChange     NextEpochChange = 0
	NextEpochToBeEnacted  NextEpochChange = 1
	NextEpochToBeRemoved  NextEpochChange = 2
	NextEpochToBeExpired  NextEpochChange = 3
	NextEpochTermAdjusted NextEpochChange = 5
)

type NextEpochChangeValue added in v0.158.0

type NextEpochChangeValue struct {
	Change        NextEpochChange
	AdjustedEpoch *uint64
}

NextEpochChangeValue represents a tagged union for next epoch changes. CBOR encoding: simple int (0-3) for most changes, or [5, epoch] for TermAdjusted

func (*NextEpochChangeValue) MarshalCBOR added in v0.158.0

func (n *NextEpochChangeValue) MarshalCBOR() ([]byte, error)

func (*NextEpochChangeValue) UnmarshalCBOR added in v0.158.0

func (n *NextEpochChangeValue) UnmarshalCBOR(data []byte) error

type NonMyopicMemberRewardsResult

type NonMyopicMemberRewardsResult map[StakeCredential]map[ledger.Blake2b224]uint64

NonMyopicMemberRewardsResult represents the non-myopic member rewards result The result is a map where each key is a stake credential and each value is a map of pool IDs to their reward amounts in lovelaces

type PoolDistrResult

type PoolDistrResult struct {
	cbor.StructAsArray
	Results map[ledger.PoolId]struct {
		cbor.StructAsArray
		StakeFraction *cbor.Rat
		VrfHash       ledger.Blake2b256
	}
}

PoolDistrResult represents the pool distribution result. It contains a map of pool IDs to their stake distribution (fraction and VRF hash)

type PoolLedgerPeers added in v0.171.0

type PoolLedgerPeers struct {
	cbor.StructAsArray
	AccumulatedStake *cbor.Rat
	Detail           PoolLedgerPeersDetail
}

PoolLedgerPeers is a single pool's entry in a LedgerPeerSnapshot. The Haskell type is (AccPoolStake, (PoolStake, NonEmpty RelayAccessPoint)) which serialises as a 2-element array containing a nested 2-element array.

AccumulatedStake is the cumulative stake fraction of all preceding pools plus this one (used by the peer-selection bisection algorithm). PoolStake is this pool's own stake fraction. Relays is the non-empty list of ledger-advertised relay endpoints.

Note: LedgerPeerSnapshot v1 does not carry a pool identity (PoolKeyHash); it is a stake-and-relays summary only.

type PoolLedgerPeersDetail added in v0.171.0

type PoolLedgerPeersDetail struct {
	cbor.StructAsArray
	PoolStake *cbor.Rat
	Relays    []RelayAccessPoint
}

PoolLedgerPeersDetail is the inner (PoolStake, NonEmpty RelayAccessPoint) pair of a PoolLedgerPeers entry.

type PoolStakeSnapshot added in v0.148.0

type PoolStakeSnapshot struct {
	cbor.StructAsArray
	StakeMark uint64 // Stake snapshot from mark
	StakeSet  uint64 // Stake snapshot from set
	StakeGo   uint64 // Stake snapshot from go
}

PoolStakeSnapshot represents the stake distribution for a pool across different snapshots

type PoolStateParams added in v0.148.0

type PoolStateParams struct {
	cbor.StructAsArray
	Operator      ledger.Blake2b224
	VrfKeyHash    ledger.Blake2b256
	Pledge        uint64
	Cost          uint64
	Margin        *cbor.Rat
	RewardAccount ledger.Address
	PoolOwners    []ledger.Blake2b224
	Relays        []ledger.PoolRelay
	PoolMetadata  *struct {
		cbor.StructAsArray
		Url          string
		MetadataHash ledger.Blake2b256
	}
}

PoolStateParams represents the pool registration parameters without the cert type

type PoolStateResult

type PoolStateResult struct {
	cbor.StructAsArray
	PState map[ledger.Blake2b224]*PoolStateParams
	FState map[ledger.Blake2b224]*PoolStateParams // Future pool parameters
	// Retiring contains pools scheduled to retire (epoch number)
	Retiring map[ledger.Blake2b224]uint64
	Deposits map[ledger.Blake2b224]uint64 // Pool deposits
}

PoolStateResult represents the pool state result The result is a 4-element array: [pstate, fstate, retiring, deposits] where pstate maps pool IDs to their registration parameters

type ProposalsResult added in v0.155.0

type ProposalsResult []GovActionState

ProposalsResult represents the result of a GetProposals query. It contains a list of governance action states for all active proposals.

type ProposedProtocolParamsUpdatesResult

type ProposedProtocolParamsUpdatesResult map[lcommon.GenesisHash]lcommon.ProtocolParameterUpdate

type QueryFunc

type QueryFunc func(CallbackContext, QueryWrapper) (any, error)

Callback function types

type QueryWrapper added in v0.106.0

type QueryWrapper struct {
	cbor.DecodeStoreCbor
	Query any
}

QueryWrapper is used for decoding a query from CBOR

func (*QueryWrapper) MarshalCBOR added in v0.106.0

func (q *QueryWrapper) MarshalCBOR() ([]byte, error)

func (*QueryWrapper) UnmarshalCBOR added in v0.106.0

func (q *QueryWrapper) UnmarshalCBOR(data []byte) error

type RatifyStateResult added in v0.158.0

type RatifyStateResult struct {
	cbor.StructAsArray
	EnactState EnactState
	Enacted    []GovActionState
	Expired    []lcommon.GovActionId
	Delayed    bool
}

RatifyStateResult represents the result of the GetRatifyState query (query ID 32). It contains the enact state, a list of enacted governance actions, a set of expired governance action IDs, and a delayed flag.

type RelayAccessPoint added in v0.171.0

type RelayAccessPoint struct {
	Kind   RelayKind
	IPv4   *net.IP
	IPv6   *net.IP
	Domain *string
	Port   *uint16
}

RelayAccessPoint is the Go representation of Haskell's RelayAccessPoint. Exactly one of IPv4, IPv6, or Domain is populated, selected by Kind:

RelayKindIPv4   -> IPv4 set, Port set
RelayKindIPv6   -> IPv6 set, Port set
RelayKindDomain -> Domain set, Port set
RelayKindSRV    -> Domain set, Port nil (resolver supplies port via SRV)

func (RelayAccessPoint) MarshalCBOR added in v0.171.0

func (r RelayAccessPoint) MarshalCBOR() ([]byte, error)

func (*RelayAccessPoint) UnmarshalCBOR added in v0.171.0

func (r *RelayAccessPoint) UnmarshalCBOR(data []byte) error

type RelayKind added in v0.171.0

type RelayKind int

RelayKind identifies the kind of relay access point in a LedgerPeerSnapshot. The integer values match the wire-format discriminator used by the Haskell Serialise instance for RelayAccessPoint.

const (
	RelayKindIPv4   RelayKind = 0 // [0, ipv4-uint32, port]
	RelayKindIPv6   RelayKind = 1 // [1, [w0,w1,w2,w3], port]
	RelayKindDomain RelayKind = 2 // [2, domain-bytes, port]
	RelayKindSRV    RelayKind = 3 // [3, domain-bytes]
)

type ReleaseFunc

type ReleaseFunc func(CallbackContext) error

Callback function types

type RewardInfoPool added in v0.161.0

type RewardInfoPool struct {
	cbor.StructAsArray
	Stake               uint64    // Absolute stake delegated to this pool (lovelace)
	OwnerPledge         uint64    // Pool owner(s) pledge (lovelace)
	OwnerStake          uint64    // Absolute stake delegated by owner(s) (lovelace)
	Cost                uint64    // Pool fixed cost (lovelace)
	Margin              *cbor.Rat // Pool margin
	PerformanceEstimate float64   // Ratio of blocks produced vs expected
}

RewardInfoPool represents per-pool reward calculation information. CBOR: array(6) [stake, ownerPledge, ownerStake, cost, margin, performanceEstimate]

type RewardInfoPoolsResult

type RewardInfoPoolsResult struct {
	Params RewardParams
	Pools  map[ledger.Blake2b224]RewardInfoPool
}

RewardInfoPoolsResult is the result of the RewardInfoPools query. CBOR: array(1)[array(2)[RewardParams, map[PoolKeyHash]RewardInfoPool]]

func (RewardInfoPoolsResult) MarshalCBOR added in v0.161.0

func (r RewardInfoPoolsResult) MarshalCBOR() ([]byte, error)

func (*RewardInfoPoolsResult) UnmarshalCBOR added in v0.161.0

func (r *RewardInfoPoolsResult) UnmarshalCBOR(data []byte) error

type RewardParams added in v0.161.0

type RewardParams struct {
	cbor.StructAsArray
	NOpt       uint16    // Desired number of stake pools (k)
	A0         *cbor.Rat // Pledge influence factor
	RPot       uint64    // Total rewards pot for the epoch (lovelace)
	TotalStake uint64    // Total active stake (lovelace)
}

RewardParams represents the global reward calculation parameters for the current epoch. CBOR: array(4) [nOpt, a0, rPot, totalStake]

type RewardProvenanceResult

type RewardProvenanceResult struct {
	EpochLength       uint64
	PoolMints         map[ledger.Blake2b224]uint64 // pool ID -> blocks minted
	MaxLovelaceSupply uint64
	DeltaR1           uint64
	DeltaR2           uint64
	R                 uint64
	TotalStake        uint64
	BlocksCount       uint64
	Decentralization  *cbor.Rat
	ExpectedBlocks    uint64
	Eta               *cbor.Rat // success rate
	RPot              uint64
	TreasuryCut       uint64
	ActiveStake       uint64
	ActiveStakeGo     cbor.RawMessage
	Pools             cbor.RawMessage
}

RewardProvenanceResult is the result of the GetRewardProvenance query. CBOR: array(1)[array(16)[epochLength, poolMints, maxLovelaceSupply, deltaR1, deltaR2, r, totalStake, blocksCount, decentralization, expectedBlocks, eta, rPot, treasuryCut, activeStake, activeStakeGo, pools]]

func (*RewardProvenanceResult) UnmarshalCBOR added in v0.161.0

func (r *RewardProvenanceResult) UnmarshalCBOR(data []byte) error

type SPOStakeDistrResult added in v0.150.0

type SPOStakeDistrResult struct {
	cbor.StructAsArray
	Results map[ledger.PoolId]uint64
}

SPOStakeDistrResult represents the SPO stake distribution for governance Maps pool IDs to their governance voting power

type Server

type Server struct {
	*protocol.Protocol
	// contains filtered or unexported fields
}

Server implements the LocalStateQuery server

func NewServer

func NewServer(protoOptions protocol.ProtocolOptions, cfg *Config) *Server

NewServer returns a new LocalStateQuery server object

type ShelleyAccountStateQuery added in v0.183.0

type ShelleyAccountStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyCborQuery added in v0.106.0

type ShelleyCborQuery struct {
	// contains filtered or unexported fields
}

type ShelleyCommitteeMembersStateQuery added in v0.150.0

type ShelleyCommitteeMembersStateQuery struct {
	cbor.StructAsArray
	Type         int
	ColdCreds    cbor.SetType[lcommon.Credential]
	HotCreds     cbor.SetType[lcommon.Credential]
	MemberStatus cbor.SetType[int]
}

type ShelleyConstitutionQuery added in v0.150.0

type ShelleyConstitutionQuery struct {
	// contains filtered or unexported fields
}

type ShelleyCurrentProtocolParamsQuery added in v0.106.0

type ShelleyCurrentProtocolParamsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyDRepStakeDistrQuery added in v0.150.0

type ShelleyDRepStakeDistrQuery struct {
	cbor.StructAsArray
	Type  int
	DReps cbor.SetType[lcommon.Drep]
}

type ShelleyDRepStateQuery added in v0.150.0

type ShelleyDRepStateQuery struct {
	cbor.StructAsArray
	Type        int
	Credentials cbor.SetType[lcommon.Credential]
}

type ShelleyDebugChainDepStateQuery added in v0.106.0

type ShelleyDebugChainDepStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyDebugEpochStateQuery added in v0.106.0

type ShelleyDebugEpochStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyDebugNewEpochStateQuery added in v0.106.0

type ShelleyDebugNewEpochStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyEpochNoQuery added in v0.106.0

type ShelleyEpochNoQuery struct {
	// contains filtered or unexported fields
}

type ShelleyFilteredDelegationAndRewardAccountsQuery added in v0.106.0

type ShelleyFilteredDelegationAndRewardAccountsQuery struct {
	cbor.StructAsArray
	Type  int
	Creds cbor.SetType[StakeCredential]
}

type ShelleyFilteredVoteDelegateesQuery added in v0.150.0

type ShelleyFilteredVoteDelegateesQuery struct {
	cbor.StructAsArray
	Type        int
	Credentials cbor.SetType[lcommon.Credential]
}

type ShelleyGenesisConfigQuery added in v0.106.0

type ShelleyGenesisConfigQuery struct {
	// contains filtered or unexported fields
}

type ShelleyGetLedgerPeerSnapshotQuery added in v0.171.0

type ShelleyGetLedgerPeerSnapshotQuery struct {
	cbor.StructAsArray
	Type     int
	PeerKind LedgerPeerKind
}

ShelleyGetLedgerPeerSnapshotQuery is the request payload for QueryTypeShelleyGetLedgerPeerSnapshot. The PeerKind field selects the ledger-peer set: LedgerPeerKindAll (default; SingAllLedgerPeers) or LedgerPeerKindBig (SingBigLedgerPeers). The PeerKind byte is the v15+ extension; older encodings used a one-element list (no PeerKind) but the query was only exposed at NtC v19+, so the byte is always present.

type ShelleyGetProposalsQuery added in v0.155.0

type ShelleyGetProposalsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyGetRatifyStateQuery added in v0.158.0

type ShelleyGetRatifyStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyGovStateQuery added in v0.150.0

type ShelleyGovStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyLedgerTipQuery added in v0.106.0

type ShelleyLedgerTipQuery struct {
	// contains filtered or unexported fields
}

type ShelleyNonMyopicMemberRewardsQuery added in v0.106.0

type ShelleyNonMyopicMemberRewardsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyPoolDistrQuery added in v0.106.0

type ShelleyPoolDistrQuery struct {
	// contains filtered or unexported fields
}

type ShelleyPoolStateQuery added in v0.106.0

type ShelleyPoolStateQuery struct {
	// contains filtered or unexported fields
}

type ShelleyProposedProtocolParamsUpdatesQuery added in v0.106.0

type ShelleyProposedProtocolParamsUpdatesQuery struct {
	// contains filtered or unexported fields
}

type ShelleyQuery added in v0.106.0

type ShelleyQuery struct {
	Era   uint
	Query any
}

func (*ShelleyQuery) MarshalCBOR added in v0.106.0

func (q *ShelleyQuery) MarshalCBOR() ([]byte, error)

func (*ShelleyQuery) UnmarshalCBOR added in v0.106.0

func (q *ShelleyQuery) UnmarshalCBOR(data []byte) error

type ShelleyRewardInfoPoolsQuery added in v0.106.0

type ShelleyRewardInfoPoolsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyRewardProvenanceQuery added in v0.106.0

type ShelleyRewardProvenanceQuery struct {
	// contains filtered or unexported fields
}

type ShelleySPOStakeDistrQuery added in v0.150.0

type ShelleySPOStakeDistrQuery struct {
	cbor.StructAsArray
	Type    int
	PoolIds cbor.SetType[ledger.PoolId]
}

type ShelleyStakeDistributionQuery added in v0.106.0

type ShelleyStakeDistributionQuery struct {
	// contains filtered or unexported fields
}

type ShelleyStakePoolParamsQuery added in v0.106.0

type ShelleyStakePoolParamsQuery struct {
	cbor.StructAsArray
	Type    int
	PoolIds cbor.SetType[ledger.PoolId]
}

type ShelleyStakePoolsQuery added in v0.106.0

type ShelleyStakePoolsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyStakeSnapshotsQuery added in v0.106.0

type ShelleyStakeSnapshotsQuery struct {
	// contains filtered or unexported fields
}

type ShelleyUtxoByAddressQuery added in v0.106.0

type ShelleyUtxoByAddressQuery struct {
	cbor.StructAsArray
	Type  int
	Addrs []lcommon.Address
}

type ShelleyUtxoByTxinQuery added in v0.106.0

type ShelleyUtxoByTxinQuery struct {
	cbor.StructAsArray
	Type  int
	TxIns []ledger.ShelleyTransactionInput
}

type ShelleyUtxoWholeQuery added in v0.106.0

type ShelleyUtxoWholeQuery struct {
	// contains filtered or unexported fields
}

type StakeCredential added in v0.153.0

type StakeCredential struct {
	cbor.StructAsArray
	Tag   uint64
	Bytes ledger.Blake2b224
}

StakeCredential represents a stake credential as [tag, bytes] where tag indicates the credential type (0 for KeyHash, 1 for ScriptHash)

type StakeDistributionResult

type StakeDistributionResult struct {
	cbor.StructAsArray
	Results map[ledger.PoolId]struct {
		cbor.StructAsArray
		StakeFraction *cbor.Rat
		VrfHash       ledger.Blake2b256
	}
}

type StakePoolParamsResult

type StakePoolParamsResult struct {
	cbor.StructAsArray
	Results map[ledger.PoolId]struct {
		cbor.StructAsArray
		Operator      ledger.Blake2b224
		VrfKeyHash    ledger.Blake2b256
		Pledge        uint
		FixedCost     uint
		Margin        *cbor.Rat
		RewardAccount ledger.Address
		PoolOwners    []ledger.Blake2b224
		Relays        []ledger.PoolRelay
		PoolMetadata  *struct {
			cbor.StructAsArray
			Url          string
			MetadataHash ledger.Blake2b256
		}
	}
}

type StakePoolsResult

type StakePoolsResult struct {
	cbor.StructAsArray
	Results []ledger.PoolId
}

type StakeSnapshotsResult

type StakeSnapshotsResult struct {
	cbor.StructAsArray
	PoolSnapshots  map[ledger.Blake2b224]*PoolStakeSnapshot
	TotalStakeMark uint64
	TotalStakeSet  uint64
	TotalStakeGo   uint64
}

StakeSnapshotsResult represents the stake snapshots result. The result is a 4-element array: [snapshots, total_stake_mark, total_stake_set, total_stake_go] where snapshots maps pool IDs to their stake distribution across mark/set/go snapshots

type SystemStartQuery added in v0.106.0

type SystemStartQuery struct {
	// contains filtered or unexported fields
}

type SystemStartResult

type SystemStartResult struct {
	cbor.StructAsArray
	Year        big.Int
	Day         int
	Picoseconds big.Int
}

func (SystemStartResult) MarshalJSON added in v0.119.0

func (s SystemStartResult) MarshalJSON() ([]byte, error)

func (SystemStartResult) String added in v0.119.0

func (s SystemStartResult) String() string

func (*SystemStartResult) UnmarshalJSON added in v0.119.0

func (s *SystemStartResult) UnmarshalJSON(data []byte) error

type UTxOByAddressResult

type UTxOByAddressResult = UTxOsResult

type UTxOByTxInResult

type UTxOByTxInResult struct {
	cbor.StructAsArray
	Results map[UtxoId]ledger.BabbageTransactionOutput
}

type UTxOWholeResult

type UTxOWholeResult = UTxOsResult

type UTxOsResult added in v0.131.0

type UTxOsResult struct {
	cbor.StructAsArray
	Results map[UtxoId]ledger.BabbageTransactionOutput
}

type UtxoId added in v0.77.0

type UtxoId struct {
	cbor.StructAsArray
	Hash      ledger.Blake2b256
	Idx       int
	DatumHash ledger.Blake2b256
}

func (*UtxoId) MarshalCBOR added in v0.106.1

func (u *UtxoId) MarshalCBOR() ([]byte, error)

func (*UtxoId) UnmarshalCBOR added in v0.77.0

func (u *UtxoId) UnmarshalCBOR(data []byte) error

type WithOriginSlot added in v0.171.0

type WithOriginSlot struct {
	HasSlot bool
	Slot    uint64
}

WithOriginSlot is the CBOR encoding of Haskell's WithOrigin SlotNo:

Origin    -> [0]
At slot   -> [1, slotNo]

HasSlot is false when the snapshot was taken at chain origin (no slot reached yet); otherwise Slot holds the SlotNo at which the snapshot was taken.

func (WithOriginSlot) MarshalCBOR added in v0.171.0

func (w WithOriginSlot) MarshalCBOR() ([]byte, error)

func (*WithOriginSlot) UnmarshalCBOR added in v0.171.0

func (w *WithOriginSlot) UnmarshalCBOR(data []byte) error

Jump to

Keyboard shortcuts

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