utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFullMethodName

func BuildFullMethodName(methodDescriptor protoreflect.MethodDescriptor) string

BuildFullMethodName constructs the full method name from the method descriptor

func ExtractGRPCField

func ExtractGRPCField[T any](
	gRPCClient *client.GRPCClient,
	methodFullName string,
	maxRetries uint,
	fieldName string,
	converter func(string) (T, error),
) (T, error)

ExtractGRPCField calls a gRPC method and extracts a specific field from the response

func GetBech32PrefixWithRetry

func GetBech32PrefixWithRetry(gRPCClient *client.GRPCClient, maxRetries uint) (string, error)

GetBech32PrefixWithRetry retrieves the Bech32 prefix from the gRPC server with retry logic.

func GetEarliestBlockHeight added in v0.11.0

func GetEarliestBlockHeight(gRPCClient *client.GRPCClient, maxRetries uint) (uint64, error)

GetEarliestBlockHeight determines the earliest available block on a node. It probes block 1 to check if the node is an archive node or pruned. For archive nodes, returns 1. For pruned nodes, parses the error message to extract the lowest available height.

func GetGRPCResponse

func GetGRPCResponse(
	gRPCClient *client.GRPCClient,
	methodFullName string,
	maxRetries uint,
	inputParams []byte,
) ([]byte, error)

GetGRPCResponse calls a gRPC method and returns the response as JSON

func GetLatestBlockHeightWithRetry

func GetLatestBlockHeightWithRetry(gRPCClient *client.GRPCClient, maxRetries uint) (uint64, error)

GetLatestBlockHeightWithRetry retrieves the latest block height from the gRPC server with retry logic.

func ParseLowestHeightFromError added in v0.11.0

func ParseLowestHeightFromError(errMsg string) uint64

ParseLowestHeightFromError extracts lowest height from pruned node errors. CosmosSDK nodes return errors like "height 1 is not available, lowest height is 28566001".

func ParseMethodFullName

func ParseMethodFullName(methodFullName string) (string, string, error)

ParseMethodFullName parses a gRPC method full name into service name and method name

func RetryGRPCCall

func RetryGRPCCall[T any](
	gRPCClient *client.GRPCClient,
	methodFullName string,
	maxRetries uint,
	callFunc func(string, protoreflect.MethodDescriptor) (T, error),
) (T, error)

RetryGRPCCall retries a gRPC call with exponential backoff

Types

type GRPCResponseFunc added in v0.11.0

type GRPCResponseFunc func(gRPCClient *client.GRPCClient, methodFullName string, maxRetries uint, inputParams []byte) ([]byte, error)

GRPCResponseFunc is a function type for getting gRPC responses, allowing dependency injection for testing.

Jump to

Keyboard shortcuts

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