rpc

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEndpoint = fmt.Sprintf("http://localhost:%d", seiconfig.PortRPC)

DefaultEndpoint is the local CometBFT RPC address.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header BlockHeader `json:"header"`
}

Block holds the subset of block fields we need.

type BlockHeader

type BlockHeader struct {
	AppHash         string `json:"app_hash"`
	LastResultsHash string `json:"last_results_hash"`
}

BlockHeader holds consensus-critical header fields for comparison.

type BlockID

type BlockID struct {
	Hash string `json:"hash"`
}

BlockID identifies a block by hash.

type BlockResult

type BlockResult struct {
	BlockID BlockID `json:"block_id"`
	Block   Block   `json:"block"`
}

BlockResult is the inner "result" of the CometBFT /block response.

type BlockResultsResult

type BlockResultsResult struct {
	TxsResults []TxResult `json:"txs_results"`
}

BlockResultsResult is the inner "result" of the CometBFT /block_results response.

type Client

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

Client performs HTTP GET requests against a CometBFT RPC endpoint and handles the JSON-RPC envelope unwrapping.

func NewClient

func NewClient(endpoint string, httpClient HTTPDoer) *Client

NewClient creates a CometBFT RPC client. Pass "" for endpoint to use the default localhost address. Pass nil for httpClient to use http.DefaultClient with no custom timeout.

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint returns the configured RPC base URL.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (json.RawMessage, error)

Get performs an HTTP GET to endpoint+path and returns the inner result as raw JSON. It handles both response formats:

  • JSON-RPC envelope (standard CometBFT): {"jsonrpc":"2.0","result":{...}} → returns the unwrapped "result" value
  • Flat JSON (seid): {"node_info":{...},"sync_info":{...}} → returns the body as-is

This dual-format support is necessary because seid's CometBFT fork returns flat responses while standard CometBFT uses JSON-RPC envelopes.

func (*Client) GetRaw

func (c *Client) GetRaw(ctx context.Context, path string) ([]byte, error)

GetRaw performs an HTTP GET and returns the entire response body without envelope unwrapping. Use for archival paths that store the verbatim JSON-RPC response (e.g., S3 export).

func (*Client) SetTimeout

func (c *Client) SetTimeout(d time.Duration)

SetTimeout overrides the per-request context timeout.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer abstracts HTTP requests for testability.

type NodeInfo

type NodeInfo struct {
	ID string `json:"id"`
	// Network is the chain ID the node is configured for; CometBFT's
	// protocol term. Compared against task params.chainId for the
	// chain-confusion guard in sidecar/tasks/sign_and_broadcast.go.
	Network string `json:"network"`
}

NodeInfo identifies a CometBFT node.

type NodeStatus

type NodeStatus struct {
	LatestBlockHeight int64
	CatchingUp        bool
}

NodeStatus holds the fields we care about from CometBFT /status.

type StatusClient

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

StatusClient queries a CometBFT node's /status endpoint.

func NewStatusClient

func NewStatusClient(endpoint string, httpClient HTTPDoer) *StatusClient

NewStatusClient creates a client targeting the given RPC endpoint. Pass "" for the default localhost endpoint. Pass nil for the default HTTP client.

func (*StatusClient) Endpoint

func (c *StatusClient) Endpoint() string

Endpoint returns the configured RPC endpoint.

func (*StatusClient) LatestHeight

func (c *StatusClient) LatestHeight(ctx context.Context) (int64, error)

LatestHeight is a convenience wrapper returning just the height.

func (*StatusClient) Status

func (c *StatusClient) Status(ctx context.Context) (*NodeStatus, error)

Status queries the node and returns the parsed status.

type StatusResult

type StatusResult struct {
	NodeInfo NodeInfo `json:"node_info"`
	SyncInfo SyncInfo `json:"sync_info"`
}

StatusResult is the inner "result" of the CometBFT /status response, after the JSON-RPC envelope has been stripped by Client.Get.

type SyncInfo

type SyncInfo struct {
	LatestBlockHeight string `json:"latest_block_height"`
	CatchingUp        bool   `json:"catching_up"`
}

SyncInfo reports chain sync state.

type TxResult

type TxResult struct {
	Code      int             `json:"code"`
	Log       string          `json:"log"`
	GasUsed   string          `json:"gas_used"`
	GasWanted string          `json:"gas_wanted"`
	Events    json.RawMessage `json:"events"`
}

TxResult holds a single transaction execution result.

Jump to

Keyboard shortcuts

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