api/rpc
Package rpc defines Broadcaster — the interface the shyware API server uses to communicate with the CometBFT node — and provides a production HTTP client implementation.
Import path: github.com/NickCarducci/Shyware-SDK/api/rpc
Broadcaster interface
type Broadcaster interface {
ABCIQuery(path string) ([]byte, error)
BroadcastTx(txBytes []byte) ([]byte, error)
Status() ([]byte, error)
}
The API server depends only on Broadcaster. Tests supply an in-process mock; production uses *Client.
Client
type Client struct { /* unexported */ }
func NewClient(baseURL string) *Client
func (c *Client) ABCIQuery(path string) ([]byte, error)
func (c *Client) BroadcastTx(txBytes []byte) ([]byte, error)
func (c *Client) Status() ([]byte, error)
NewClient takes the CometBFT RPC base URL (e.g. http://127.0.0.1:26657). The API server creates a client at startup from the --cometbft-rpc flag.
Usage in ABCI binaries
// In shyvoting-api/main.go:
client := rpc.NewClient(*cometbftRPC) // wraps CometBFT
srv := server.NewServer(client, ...)
http.ListenAndServe(":8080", srv.Router())
ABCIQuery
ABCIQuery sends a GET /abci_query request to CometBFT, which routes to the shyware ABCI app's Query method. The path parameter is the domain-specific query path (e.g. /polls/poll-1, /supply/usdc).
BroadcastTx
BroadcastTx sends broadcast_tx_sync to CometBFT. The tx bytes are the JSON-encoded tx.Tx struct, marshalled by the domain-specific build step before submission. CometBFT validates the tx through CheckTx before adding to the mempool; FinalizeBlock executes it at consensus.
Status
Status returns the raw CometBFT status response — used by the /health endpoint to surface node sync state and latest block height.