rpc

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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 added in v0.0.31

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

Block holds the subset of block fields we need.

type BlockHeader added in v0.0.31

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

BlockHeader holds consensus-critical header fields for comparison.

type BlockID added in v0.0.31

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

BlockID identifies a block by hash.

type BlockResult added in v0.0.31

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

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

type BlockResultsResult added in v0.0.31

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

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

type Client added in v0.0.31

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 added in v0.0.31

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 added in v0.0.31

func (c *Client) Endpoint() string

Endpoint returns the configured RPC base URL.

func (*Client) Get added in v0.0.31

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 added in v0.0.31

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 added in v0.0.31

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

SetTimeout overrides the per-request context timeout.

type HTTPDoer added in v0.0.31

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

HTTPDoer abstracts HTTP requests for testability.

type NodeInfo added in v0.0.31

type NodeInfo struct {
	ID string `json:"id"`
}

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 added in v0.0.31

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 added in v0.0.31

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

SyncInfo reports chain sync state.

type TxResult added in v0.0.31

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