Documentation ¶
Index ¶
- type Account
- type AccountBalance
- type AccountClient
- type AccountMetrics
- type AccountTask
- type Block
- type BlockHeightTask
- type Chain
- type Client
- type Endpoint
- type HTTPClient
- type JailStatus
- type Metrics
- type RestClient
- func (c RestClient) AccountBalance(ctx context.Context, account, denom string) (AccountBalance, error)
- func (c RestClient) LatestBlock(ctx context.Context) (Block, error)
- func (c RestClient) SigningInfo(ctx context.Context, consaddress string) (SigningInfo, error)
- func (c RestClient) SlashingParams(ctx context.Context) (SlashingParams, error)
- type SigningInfo
- type SlashingParams
- type ValParamsClient
- type ValParamsMetrics
- type ValParamsTask
- type Validator
- type ValidatorClient
- type ValidatorMetrics
- type ValidatorTask
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountBalance ¶
type AccountClient ¶
type AccountClient interface {
AccountBalance(ctx context.Context, address, denom string) (AccountBalance, error)
}
type AccountMetrics ¶
type AccountTask ¶
type AccountTask struct {
// contains filtered or unexported fields
}
AccountTask queries the Cosmos REST (aka LCD) API for account data and records metrics.
func NewAccountTasks ¶
func NewAccountTasks(metrics AccountMetrics, client AccountClient, chain Chain) []AccountTask
func (AccountTask) Group ¶
func (task AccountTask) Group() string
func (AccountTask) ID ¶
func (task AccountTask) ID() string
func (AccountTask) Interval ¶
func (task AccountTask) Interval() time.Duration
Interval is how often to poll the Endpoint server for data. Defaults to 5s.
type Block ¶
type Block struct { BlockID struct { Hash string `json:"hash"` Parts struct { Total int `json:"total"` Hash string `json:"hash"` } `json:"parts"` } `json:"block_id"` Block struct { Header struct { Version struct { Block string `json:"block"` } `json:"version"` ChainID string `json:"chain_id"` Height string `json:"height"` Time time.Time `json:"time"` LastBlockID struct { Hash string `json:"hash"` Parts struct { Total int `json:"total"` Hash string `json:"hash"` } `json:"parts"` } `json:"last_block_id"` LastCommitHash string `json:"last_commit_hash"` DataHash string `json:"data_hash"` ValidatorsHash string `json:"validators_hash"` NextValidatorsHash string `json:"next_validators_hash"` ConsensusHash string `json:"consensus_hash"` AppHash string `json:"app_hash"` LastResultsHash string `json:"last_results_hash"` EvidenceHash string `json:"evidence_hash"` ProposerAddress string `json:"proposer_address"` } `json:"header"` Data struct { Txs []string `json:"txs"` } `json:"data"` Evidence struct { Evidence []any `json:"evidence"` } `json:"evidence"` LastCommit struct { Height string `json:"height"` Round int `json:"round"` BlockID struct { Hash string `json:"hash"` Parts struct { Total int `json:"total"` Hash string `json:"hash"` } `json:"parts"` } `json:"block_id"` Signatures []struct { BlockIDFlag string `json:"block_id_flag"` ValidatorAddress string `json:"validator_address"` Timestamp time.Time `json:"timestamp"` Signature string `json:"signature"` } `json:"signatures"` } `json:"last_commit"` } `json:"block"` }
type BlockHeightTask ¶
type BlockHeightTask struct {
// contains filtered or unexported fields
}
BlockHeightTask queries the Cosmos REST (aka LCD) API for data and records various metrics.
func NewBlockHeightTask ¶
func NewBlockHeightTask(metrics Metrics, client Client, chain Chain) BlockHeightTask
func (BlockHeightTask) Group ¶
func (task BlockHeightTask) Group() string
func (BlockHeightTask) ID ¶
func (task BlockHeightTask) ID() string
func (BlockHeightTask) Interval ¶
func (task BlockHeightTask) Interval() time.Duration
Interval is how often to poll the Endpoint server for data. Defaults to 5s.
type HTTPClient ¶
type JailStatus ¶
type JailStatus int
JailStatus is the status of a validator.
const ( JailStatusActive JailStatus = iota JailStatusJailed JailStatusTombstoned )
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
RestClient is a client for the Cosmos REST API. To find a list of endpoints, try: https://docs.cosmos.network/swagger/
func NewRestClient ¶
func NewRestClient(c HTTPClient) *RestClient
func (RestClient) AccountBalance ¶
func (c RestClient) AccountBalance(ctx context.Context, account, denom string) (AccountBalance, error)
AccountBalance returns the balance of an account. The account is a bech32 address with prefix. The denom is likely lowercase, e.g. "uatom". To query ibc denoms use the prefix "ibc/hash", e.g. "ibc/E7D5E9D0E9BF8B7354929A817DD28D4D017E745F638954764AA88522A7A409EC" If the denom is not found, API returns a balance of 0 instead of an error.
func (RestClient) LatestBlock ¶
func (c RestClient) LatestBlock(ctx context.Context) (Block, error)
LatestBlock queries the latest block from the Cosmos REST API given the baseURL.
func (RestClient) SigningInfo ¶
func (c RestClient) SigningInfo(ctx context.Context, consaddress string) (SigningInfo, error)
SigningInfo returns the signing status of a validator given the consensus address. Docs: https://docs.cosmos.network/swagger/#/Query/SigningInfo
func (RestClient) SlashingParams ¶
func (c RestClient) SlashingParams(ctx context.Context) (SlashingParams, error)
SlashingParams returns the slashing parameters. Docs: https://docs.cosmos.network/swagger/#/Query/SlashingParams
type SigningInfo ¶
type SigningInfo struct { ValSigningInfo struct { Address string `json:"address"` StartHeight string `json:"start_height"` IndexOffset string `json:"index_offset"` JailedUntil time.Time `json:"jailed_until"` Tombstoned bool `json:"tombstoned"` MissedBlocksCounter string `json:"missed_blocks_counter"` } `json:"val_signing_info"` }
SigningInfo determines whether a validator is jailed or not.
type SlashingParams ¶
type SlashingParams struct { Params struct { SignedBlocksWindow string `json:"signed_blocks_window"` MinSignedPerWindow string `json:"min_signed_per_window"` DowntimeJailDuration string `json:"downtime_jail_duration"` SlashFractionDoubleSign string `json:"slash_fraction_double_sign"` SlashFractionDowntime string `json:"slash_fraction_downtime"` } `json:"params"` }
func (SlashingParams) SignedBlocksWindow ¶
func (s SlashingParams) SignedBlocksWindow() float64
type ValParamsClient ¶
type ValParamsClient interface {
SlashingParams(ctx context.Context) (SlashingParams, error)
}
type ValParamsMetrics ¶
type ValParamsTask ¶
type ValParamsTask struct {
// contains filtered or unexported fields
}
func NewValParamsTask ¶
func NewValParamsTask(metrics ValParamsMetrics, client ValParamsClient, chain Chain) ValParamsTask
func (ValParamsTask) Group ¶
func (p ValParamsTask) Group() string
func (ValParamsTask) ID ¶
func (p ValParamsTask) ID() string
func (ValParamsTask) Interval ¶
func (p ValParamsTask) Interval() time.Duration
Interval is hardcoded to a longer duration because params rarely change. They require a gov proposal. Additionally, longer duration minimizes API calls to prevent hitting rate limits.
type Validator ¶
type Validator struct { // The validator's consensus address. Example prefix: cosmosvalcons... ConsAddress string }
type ValidatorClient ¶
type ValidatorMetrics ¶
type ValidatorTask ¶
type ValidatorTask struct {
// contains filtered or unexported fields
}
ValidatorTask queries the Cosmos REST (aka LCD) API for data and records metrics specific to a validator. It records: - whether the validator is jailed or tombstoned - the number of blocks signed by the validator - the number of validator missed blocks
func BuildValidatorTasks ¶
func BuildValidatorTasks(metrics ValidatorMetrics, client ValidatorClient, chain Chain) []ValidatorTask
func (ValidatorTask) Group ¶
func (task ValidatorTask) Group() string
func (ValidatorTask) ID ¶
func (task ValidatorTask) ID() string
func (ValidatorTask) Interval ¶
func (task ValidatorTask) Interval() time.Duration