client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Note that no auto-generated gRPC code is directly exposed via the client interface. This is on purpose to minimize the potential impact on users of switching to Google's Go code generator in future. See https://github.com/zeu5/cometbft/issues/731 for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	BlockID *types.BlockID `json:"block_id"`
	Block   *types.Block   `json:"block"`
}

Block data returned by the CometBFT BlockService gRPC API.

type BlockResults

type BlockResults struct {
	Height                int64                     `json:"height"`
	TxsResults            []*abci.ExecTxResult      `json:"txs_results"`
	FinalizeBlockEvents   []*abci.Event             `json:"finalize_block_events"`
	ValidatorUpdates      []*abci.ValidatorUpdate   `json:"validator_updates"`
	ConsensusParamUpdates *cmtproto.ConsensusParams `json:"consensus_param_updates"`
	AppHash               []byte                    `json:"app_hash"`
}

type BlockResultsServiceClient

type BlockResultsServiceClient interface {
	GetBlockResults(ctx context.Context, height int64) (*BlockResults, error)
	GetLatestBlockResults(ctx context.Context) (*BlockResults, error)
}

BlockResultsServiceClient provides the block results of a given height (or latest if none provided).

type BlockServiceClient

type BlockServiceClient interface {
	// GetBlockByHeight attempts to retrieve the block associated with the
	// given height.
	GetBlockByHeight(ctx context.Context, height int64) (*Block, error)

	// GetLatestBlock attempts to retrieve the latest committed block.
	GetLatestBlock(ctx context.Context) (*Block, error)

	// GetLatestHeight provides sends the latest committed block height to the
	// resulting output channel as blocks are committed.
	GetLatestHeight(ctx context.Context, opts ...GetLatestHeightOption) (<-chan LatestHeightResult, error)
}

BlockServiceClient provides block information

type Client

type Client interface {
	VersionServiceClient
	BlockServiceClient
	BlockResultsServiceClient

	// Close the connection to the server. Any subsequent requests will fail.
	Close() error
}

Client defines the full client interface for interacting with a CometBFT node via gRPC.

func New

func New(ctx context.Context, addr string, opts ...Option) (Client, error)

New constructs a client for interacting with a CometBFT node via gRPC.

Makes no assumptions about whether or not to use TLS to connect to the given address. To connect to a gRPC server without using TLS, use the WithInsecure option.

To connect to a gRPC server with TLS, use the WithGRPCDialOption option with the appropriate gRPC credentials configuration. See https://pkg.go.dev/google.golang.org/grpc#WithTransportCredentials

type GetLatestHeightOption

type GetLatestHeightOption func(*getLatestHeightConfig)

func GetLatestHeightChannelSize

func GetLatestHeightChannelSize(sz uint) GetLatestHeightOption

GetLatestHeightChannelSize allows control over the channel size. If not used or the channel size is set to 0, an unbuffered channel will be created.

type LatestHeightResult

type LatestHeightResult struct {
	Height int64
	Error  error
}

LatestHeightResult type used in GetLatestResult and send to the client via a channel

type Option

type Option func(*clientBuilder)

func WithBlockServiceEnabled

func WithBlockServiceEnabled(enabled bool) Option

WithBlockServiceEnabled allows control of whether or not to create a client for interacting with the block service of a CometBFT node.

If disabled and the client attempts to access the block service API, the client will panic.

func WithGRPCDialOption

func WithGRPCDialOption(opt ggrpc.DialOption) Option

WithGRPCDialOption allows passing lower-level gRPC dial options through to the gRPC dialer when creating the client.

func WithInsecure

func WithInsecure() Option

WithInsecure disables transport security for the underlying client connection.

A shortcut for using grpc.WithTransportCredentials and insecure.NewCredentials from google.golang.org/grpc.

func WithVersionServiceEnabled

func WithVersionServiceEnabled(enabled bool) Option

WithVersionServiceEnabled allows control of whether or not to create a client for interacting with the version service of a CometBFT node.

If disabled and the client attempts to access the version service API, the client will panic.

type Version

type Version struct {
	Node  string // The semantic version of the node software (i.e. the version of CometBFT).
	ABCI  string // The version of the ABCI protocol used by the node.
	P2P   uint64 // The version of the P2P protocol used by the node.
	Block uint64 // The version of the block protocol used by the node.
}

Version provides version information about a particular CometBFT node.

type VersionServiceClient

type VersionServiceClient interface {
	GetVersion(ctx context.Context) (*Version, error)
}

VersionServiceClient provides version information about a CometBFT node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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