cosmos

package
v0.10.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PodFilter added in v0.8.0

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

PodFilter queries tendermint for block heights.

func NewPodFilter added in v0.8.0

func NewPodFilter(status TendermintStatuser) *PodFilter

func (PodFilter) SyncedPods added in v0.8.0

func (filter PodFilter) SyncedPods(ctx context.Context, log kube.Logger, candidates []*corev1.Pod) []*corev1.Pod

SyncedPods returns all pods that are in sync (i.e. no longer catching up). Caller is responsible for timeouts via the context.

type TendermintClient

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

TendermintClient knows how to make requests to the Tendermint RPC endpoints. This package uses a custom client because 1) parsing JSON is simple and 2) we prevent any dependency on tendermint packages.

func NewTendermintClient

func NewTendermintClient(client *http.Client) *TendermintClient

func (*TendermintClient) Status

func (client *TendermintClient) Status(ctx context.Context, rpcHost string) (TendermintStatus, error)

Status finds the current Tendermint status.

type TendermintStatus

type TendermintStatus struct {
	JSONRPC string `json:"jsonrpc"`
	ID      int    `json:"id"`
	Result  struct {
		NodeInfo struct {
			ProtocolVersion struct {
				P2P   string `json:"p2p"`
				Block string `json:"block"`
				App   string `json:"app"`
			} `json:"protocol_version"`
			ID         string `json:"id"`
			ListenAddr string `json:"listen_addr"`
			Network    string `json:"network"`
			Version    string `json:"version"`
			Channels   string `json:"channels"`
			Moniker    string `json:"moniker"`
			Other      struct {
				TxIndex    string `json:"tx_index"`
				RPCAddress string `json:"rpc_address"`
			} `json:"other"`
		} `json:"node_info"`
		SyncInfo struct {
			LatestBlockHash     string    `json:"latest_block_hash"`
			LatestAppHash       string    `json:"latest_app_hash"`
			LatestBlockHeight   string    `json:"latest_block_height"`
			LatestBlockTime     time.Time `json:"latest_block_time"`
			EarliestBlockHash   string    `json:"earliest_block_hash"`
			EarliestAppHash     string    `json:"earliest_app_hash"`
			EarliestBlockHeight string    `json:"earliest_block_height"`
			EarliestBlockTime   time.Time `json:"earliest_block_time"`
			CatchingUp          bool      `json:"catching_up"`
		} `json:"sync_info"`
		ValidatorInfo struct {
			Address string `json:"address"`
			PubKey  struct {
				Type  string `json:"type"`
				Value string `json:"value"`
			} `json:"pub_key"`
			VotingPower string `json:"voting_power"`
		} `json:"validator_info"`
	} `json:"result"`
}

TendermintStatus is the response from the /status RPC endpoint.

func (TendermintStatus) LatestBlockHeight

func (status TendermintStatus) LatestBlockHeight() uint64

LatestBlockHeight parses the latest block height string. If the string is malformed, returns 0.

type TendermintStatuser

type TendermintStatuser interface {
	Status(ctx context.Context, rpcHost string) (TendermintStatus, error)
}

TendermintStatuser calls the Tendermint RPC status endpoint.

Jump to

Keyboard shortcuts

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