Documentation ¶
Overview ¶
Package localstatequery implements the Ouroboros local-state-query protocol
Index ¶
- Constants
- Variables
- func NewMsgFromCbor(msgType uint, data []byte) (protocol.Message, error)
- type AcquireFailurePointNotOnChainError
- type AcquireFailurePointTooOldError
- type AcquireFunc
- type CallbackContext
- type Client
- func (c *Client) Acquire(point *common.Point) error
- func (c *Client) DebugChainDepState() (*DebugChainDepStateResult, error)
- func (c *Client) DebugEpochState() (*DebugEpochStateResult, error)
- func (c *Client) DebugNewEpochState() (*DebugNewEpochStateResult, error)
- func (c *Client) GetChainBlockNo() (int64, error)
- func (c *Client) GetChainPoint() (*common.Point, error)
- func (c *Client) GetCurrentEra() (int, error)
- func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
- func (c *Client) GetEpochNo() (int, error)
- func (c *Client) GetEraHistory() ([]EraHistoryResult, error)
- func (c *Client) GetFilteredDelegationsAndRewardAccounts(creds []interface{}) (*FilteredDelegationsAndRewardAccountsResult, error)
- func (c *Client) GetGenesisConfig() (*GenesisConfigResult, error)
- func (c *Client) GetNonMyopicMemberRewards() (*NonMyopicMemberRewardsResult, error)
- func (c *Client) GetPoolDistr(poolIds []interface{}) (*PoolDistrResult, error)
- func (c *Client) GetPoolState(poolIds []interface{}) (*PoolStateResult, error)
- func (c *Client) GetProposedProtocolParamsUpdates() (*ProposedProtocolParamsUpdatesResult, error)
- func (c *Client) GetRewardInfoPools() (*RewardInfoPoolsResult, error)
- func (c *Client) GetRewardProvenance() (*RewardProvenanceResult, error)
- func (c *Client) GetStakeDistribution() (*StakeDistributionResult, error)
- func (c *Client) GetStakePoolParams(poolIds []ledger.PoolId) (*StakePoolParamsResult, error)
- func (c *Client) GetStakePools() (*StakePoolsResult, error)
- func (c *Client) GetStakeSnapshots(poolId interface{}) (*StakeSnapshotsResult, error)
- func (c *Client) GetSystemStart() (*SystemStartResult, error)
- func (c *Client) GetUTxOByAddress(addrs []ledger.Address) (*UTxOByAddressResult, error)
- func (c *Client) GetUTxOByTxIn(txIns []ledger.TransactionInput) (*UTxOByTxInResult, error)
- func (c *Client) GetUTxOWhole() (*UTxOWholeResult, error)
- func (c *Client) Release() error
- func (c *Client) Start()
- type Config
- type CurrentProtocolParamsResult
- type DebugChainDepStateResult
- type DebugEpochStateResult
- type DebugNewEpochStateResult
- type DoneFunc
- type EraHistoryResult
- type FilteredDelegationsAndRewardAccountsResult
- type GenesisConfigResult
- type LocalStateQuery
- type LocalStateQueryOptionFunc
- func WithAcquireFunc(acquireFunc AcquireFunc) LocalStateQueryOptionFunc
- func WithAcquireTimeout(timeout time.Duration) LocalStateQueryOptionFunc
- func WithDoneFunc(doneFunc DoneFunc) LocalStateQueryOptionFunc
- func WithQueryFunc(queryFunc QueryFunc) LocalStateQueryOptionFunc
- func WithQueryTimeout(timeout time.Duration) LocalStateQueryOptionFunc
- func WithReAcquireFunc(reAcquireFunc ReAcquireFunc) LocalStateQueryOptionFunc
- func WithReleaseFunc(releaseFunc ReleaseFunc) LocalStateQueryOptionFunc
- type MsgAcquire
- type MsgAcquireNoPoint
- type MsgAcquired
- type MsgDone
- type MsgFailure
- type MsgQuery
- type MsgReAcquire
- type MsgReAcquireNoPoint
- type MsgRelease
- type MsgResult
- type NonMyopicMemberRewardsResult
- type PoolDistrResult
- type PoolStateResult
- type ProposedProtocolParamsUpdatesResult
- type QueryFunc
- type ReAcquireFunc
- type ReleaseFunc
- type RewardInfoPoolsResult
- type RewardProvenanceResult
- type Server
- type StakeDistributionResult
- type StakePoolParamsResult
- type StakePoolsResult
- type StakeSnapshotsResult
- type SystemStartResult
- type UTxOByAddressResult
- type UTxOByTxInResult
- type UTxOWholeResult
- type UtxoId
Constants ¶
const ( ProtocolName = "local-state-query" ProtocolId uint16 = 7 )
Protocol identifiers
const ( MessageTypeAcquire = 0 MessageTypeAcquired = 1 MessageTypeFailure = 2 MessageTypeQuery = 3 MessageTypeResult = 4 MessageTypeRelease = 5 MessageTypeReacquire = 6 MessageTypeDone = 7 MessageTypeAcquireNoPoint = 8 MessageTypeReacquireNoPoint = 9 )
Message types
const ( AcquireFailurePointTooOld = 0 AcquireFailurePointNotOnChain = 1 )
Acquire failure reasons
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 )
Query types
Variables ¶
var StateMap = protocol.StateMap{ // contains filtered or unexported fields }
LocalStateQuery protocol state machine
Functions ¶
Types ¶
type AcquireFailurePointNotOnChainError ¶
type AcquireFailurePointNotOnChainError struct { }
AcquireFailurePointNotOnChainError indicates a failure to acquire a point due to it not being present on the chain
func (AcquireFailurePointNotOnChainError) Error ¶
func (e AcquireFailurePointNotOnChainError) Error() string
type AcquireFailurePointTooOldError ¶
type AcquireFailurePointTooOldError struct { }
AcquireFailurePointTooOldError indicates a failure to acquire a point due to it being too old
func (AcquireFailurePointTooOldError) Error ¶
func (e AcquireFailurePointTooOldError) Error() string
type AcquireFunc ¶
type AcquireFunc func(CallbackContext, *common.Point) error
Callback function types
type CallbackContext ¶ added in v0.78.0
type CallbackContext struct { ConnectionId connection.ConnectionId Client *Client Server *Server }
Callback context
type Client ¶
Client implements the LocalStateQuery client
func NewClient ¶
func NewClient(protoOptions protocol.ProtocolOptions, cfg *Config) *Client
NewClient returns a new LocalStateQuery client object
func (*Client) DebugChainDepState ¶
func (c *Client) DebugChainDepState() (*DebugChainDepStateResult, error)
TODO
func (*Client) DebugEpochState ¶
func (c *Client) DebugEpochState() (*DebugEpochStateResult, error)
TODO
func (*Client) DebugNewEpochState ¶
func (c *Client) DebugNewEpochState() (*DebugNewEpochStateResult, error)
TODO
func (*Client) GetChainBlockNo ¶
GetChainBlockNo returns the latest block number
func (*Client) GetChainPoint ¶
GetChainPoint returns the current chain tip
func (*Client) GetCurrentEra ¶
GetCurrentEra returns the current era ID
func (*Client) GetCurrentProtocolParams ¶
func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
GetCurrentProtocolParams returns the set of protocol params that are currently in effect
func (*Client) GetEpochNo ¶
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 []interface{}, ) (*FilteredDelegationsAndRewardAccountsResult, error)
TODO
query [10 #6.258([ *rwdr ])]
func (*Client) GetGenesisConfig ¶
func (c *Client) GetGenesisConfig() (*GenesisConfigResult, error)
func (*Client) GetNonMyopicMemberRewards ¶
func (c *Client) GetNonMyopicMemberRewards() (*NonMyopicMemberRewardsResult, error)
TODO
query [2 #6.258([*[0 int]]) int is the stake the user intends to delegate, the array must be sorted
func (*Client) GetPoolDistr ¶
func (c *Client) GetPoolDistr(poolIds []interface{}) (*PoolDistrResult, error)
TODO
func (*Client) GetPoolState ¶
func (c *Client) GetPoolState(poolIds []interface{}) (*PoolStateResult, error)
TODO
func (*Client) GetProposedProtocolParamsUpdates ¶
func (c *Client) GetProposedProtocolParamsUpdates() (*ProposedProtocolParamsUpdatesResult, error)
func (*Client) GetRewardInfoPools ¶
func (c *Client) GetRewardInfoPools() (*RewardInfoPoolsResult, error)
TODO
func (*Client) GetRewardProvenance ¶
func (c *Client) GetRewardProvenance() (*RewardProvenanceResult, error)
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( poolId interface{}, ) (*StakeSnapshotsResult, error)
TODO
func (*Client) GetSystemStart ¶
func (c *Client) GetSystemStart() (*SystemStartResult, error)
GetSystemStart returns the SystemStart value
func (*Client) GetUTxOByAddress ¶
func (c *Client) GetUTxOByAddress( addrs []ledger.Address, ) (*UTxOByAddressResult, error)
func (*Client) GetUTxOByTxIn ¶
func (c *Client) GetUTxOByTxIn( txIns []ledger.TransactionInput, ) (*UTxOByTxInResult, error)
func (*Client) GetUTxOWhole ¶
func (c *Client) GetUTxOWhole() (*UTxOWholeResult, error)
type Config ¶
type Config struct { AcquireFunc AcquireFunc QueryFunc QueryFunc ReleaseFunc ReleaseFunc ReAcquireFunc ReAcquireFunc DoneFunc DoneFunc 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 CurrentProtocolParamsResult ¶
type CurrentProtocolParamsResult interface { ledger.BabbageProtocolParameters | any // TODO: add more per-era types }
type DoneFunc ¶
type DoneFunc func(CallbackContext) error
type EraHistoryResult ¶
type EraHistoryResult struct { Begin eraHistoryResultBeginEnd End eraHistoryResultBeginEnd Params eraHistoryResultParams // contains filtered or unexported fields }
type FilteredDelegationsAndRewardAccountsResult ¶
type FilteredDelegationsAndRewardAccountsResult interface{}
TODO
rwdr [flag bytestring] bytestring is the keyhash of the staking vkey flag 0/1 0=keyhash 1=scripthash result [[ delegation rewards] ] delegation { * rwdr => poolid } poolid is a bytestring rewards { * rwdr => int } It seems to be a requirement to sort the reward addresses on the query. Scripthash addresses come first, then within a group the bytestring being a network order integer sort ascending.
type GenesisConfigResult ¶
type GenesisConfigResult struct { Start SystemStartResult NetworkMagic int NetworkId uint8 ActiveSlotsCoeff []interface{} SecurityParam int EpochLength int SlotsPerKESPeriod int MaxKESEvolutions int SlotLength int UpdateQuorum int MaxLovelaceSupply int64 ProtocolParams struct { 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 interface{} ProtocolVersionMajor int ProtocolVersionMinor int MinUTxOValue int MinPoolCost int // contains filtered or unexported fields } // This value contains maps with bytestring keys, which we can't parse yet GenDelegs cbor.RawMessage Unknown1 interface{} Unknown2 interface{} // contains filtered or unexported fields }
type LocalStateQuery ¶
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 WithDoneFunc ¶
func WithDoneFunc(doneFunc DoneFunc) LocalStateQueryOptionFunc
WithDoneFunc specifies the Done callback function when acting as a server
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 WithReAcquireFunc ¶
func WithReAcquireFunc(reAcquireFunc ReAcquireFunc) LocalStateQueryOptionFunc
WithReAcquireFunc specifies the ReAcquire callback function when acting as a server
func WithReleaseFunc ¶
func WithReleaseFunc(releaseFunc ReleaseFunc) LocalStateQueryOptionFunc
WithReleaseFunc specifies the Release callback function when acting as a server
type MsgAcquire ¶
type MsgAcquire struct { protocol.MessageBase Point common.Point }
func NewMsgAcquire ¶
func NewMsgAcquire(point common.Point) *MsgAcquire
type MsgAcquireNoPoint ¶
type MsgAcquireNoPoint struct {
protocol.MessageBase
}
func NewMsgAcquireNoPoint ¶
func NewMsgAcquireNoPoint() *MsgAcquireNoPoint
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 interface{} }
func NewMsgQuery ¶
func NewMsgQuery(query interface{}) *MsgQuery
type MsgReAcquire ¶
type MsgReAcquire struct { protocol.MessageBase Point common.Point }
func NewMsgReAcquire ¶
func NewMsgReAcquire(point common.Point) *MsgReAcquire
type MsgReAcquireNoPoint ¶
type MsgReAcquireNoPoint struct {
protocol.MessageBase
}
func NewMsgReAcquireNoPoint ¶
func NewMsgReAcquireNoPoint() *MsgReAcquireNoPoint
type MsgRelease ¶
type MsgRelease struct {
protocol.MessageBase
}
func NewMsgRelease ¶
func NewMsgRelease() *MsgRelease
type MsgResult ¶
type MsgResult struct { protocol.MessageBase Result cbor.RawMessage }
func NewMsgResult ¶
type NonMyopicMemberRewardsResult ¶
type NonMyopicMemberRewardsResult interface{}
TODO
result [{ *[0 int] => non_myopic_rewards }] for each stake display reward non_myopic_rewards { *poolid => int } int is the amount of lovelaces each pool would reward
type ProposedProtocolParamsUpdatesResult ¶
type ProposedProtocolParamsUpdatesResult interface{}
TODO
type QueryFunc ¶
type QueryFunc func(CallbackContext, any) error
type ReAcquireFunc ¶
type ReAcquireFunc func(CallbackContext, *common.Point) error
type ReleaseFunc ¶
type ReleaseFunc func(CallbackContext) error
type RewardProvenanceResult ¶
type RewardProvenanceResult interface{}
TODO
result [ *Element ] Expanded in order on the next rows. Element CDDL Comment epochLength poolMints { *poolid => block-count } maxLovelaceSupply NA NA NA ?circulatingsupply? total-blocks ?decentralization? [num den] ?available block entries success-rate [num den] NA NA ??treasuryCut activeStakeGo nil nil
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 SystemStartResult ¶
type UTxOByAddressResult ¶
type UTxOByAddressResult struct { cbor.StructAsArray Results map[UtxoId]ledger.BabbageTransactionOutput }
type UTxOByTxInResult ¶
type UTxOByTxInResult 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 }