Documentation
¶
Index ¶
- func FetchBlocks(ctx context.Context, rpc *rpcclient.HTTP, fromHeight, toHeight int64) ([]*coretypes.ResultBlock, []*coretypes.ResultBlockResults, error)
- type Node
- type Nodes
- func (nodes Nodes) ByHeightRange(minHeight, maxHeight int64) Nodes
- func (nodes Nodes) ConstrainByVersion(c semver.Constraints) Nodes
- func (nodes Nodes) EarliestAvailableHeight() int64
- func (nodes Nodes) LatestAvailableHeight() int64
- func (nodes Nodes) LatestVersion() Nodes
- func (nodes Nodes) PickRandom() Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchBlocks ¶
func FetchBlocks(ctx context.Context, rpc *rpcclient.HTTP, fromHeight, toHeight int64) ( []*coretypes.ResultBlock, []*coretypes.ResultBlockResults, error)
FetchBlocks fetches blocks and their results from the CometBFT RPC server.
Types ¶
type Node ¶
type Node struct {
Id string
RemoteURL string
AppVersion *semver.Version
EarliestHeight int64
LatestHeight int64
RPC *rpcclient.HTTP
}
Node represents a cometbft node with its remote address, application version, and base height.
type Nodes ¶
type Nodes []Node
Nodes is a slice of Node, representing a collection of discovered nodes.
func DiscoverNodes ¶
func DiscoverNodes( ctx context.Context, remotes []string, expand bool, logger *slog.Logger, ) (Nodes, error)
DiscoverNodes fetches some basic information about the nodes from the given remotes. If `expand` is true, it will also expand the remotes by querying the the chain network info.
func (Nodes) ByHeightRange ¶
ByHeightRange filters the discovered nodes by the given height range.
func (Nodes) ConstrainByVersion ¶
func (nodes Nodes) ConstrainByVersion(c semver.Constraints) Nodes
ConstrainByVersion filters the discovered nodes by the given semver constraints.
func (Nodes) EarliestAvailableHeight ¶
EarliestAvailableHeight returns the minimum earliest height among the discovered nodes.
func (Nodes) LatestAvailableHeight ¶
LatestAvailableHeight returns the maximum latest height among the discovered nodes.
func (Nodes) LatestVersion ¶
LatestVersion returns the nodes with the latest application version.
func (Nodes) PickRandom ¶
PickRandom returns a random node from the discovered nodes. If the slice is empty, it returns nil.