Documentation ¶
Overview ¶
Package hcnetcore is a client library for communicating with an instance of hcnet-core using through the server's HTTP port.
Index ¶
- Constants
- type Client
- func (c *Client) GetLedgerEntry(ctx context.Context, ledgerKey xdr.LedgerKey) (proto.GetLedgerEntryResponse, error)
- func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error)
- func (c *Client) ManualClose(ctx context.Context) (err error)
- func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) (err error)
- func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp *proto.TXResponse, err error)
- func (c *Client) Upgrade(ctx context.Context, version int) (err error)
- func (c *Client) WaitForNetworkSync(ctx context.Context) error
- type ClientWithMetrics
- type HTTP
Examples ¶
Constants ¶
const SetCursorDone = "Done"
SetCursorDone is the success message returned by hcnet-core when a cursor update succeeds.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTP is the client to use when communicating with hcnet-core. If nil, // http.DefaultClient will be used. HTTP HTTP // URL of Hcnet Core server to connect. URL string }
Client represents a client that is capable of communicating with a hcnet-core server using HTTP
func (*Client) GetLedgerEntry ¶ added in v1.11.1
func (c *Client) GetLedgerEntry(ctx context.Context, ledgerKey xdr.LedgerKey) (proto.GetLedgerEntryResponse, error)
GetLedgerEntry submits a request to the hcnet core instance to get the latest state of a given ledger entry.
func (*Client) Info ¶
Info calls the `info` command on the connected hcnet core and returns the provided response
Example ¶
client := &Client{URL: "http://localhost:11626"} info, err := client.Info(context.Background()) if err != nil { panic(err) } fmt.Printf("synced: %v", info.IsSynced())
Output:
func (*Client) ManualClose ¶ added in v1.11.1
ManualClose closes a ledger when Core is running in `MANUAL_CLOSE` mode
func (*Client) SubmitTransaction ¶
func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp *proto.TXResponse, err error)
SubmitTransaction calls the `tx` command on the connected hcnet core with the provided envelope
type ClientWithMetrics ¶ added in v1.11.1
type ClientWithMetrics struct {
// contains filtered or unexported fields
}
func NewClientWithMetrics ¶ added in v1.11.1
func NewClientWithMetrics(client Client, registry *prometheus.Registry, prometheusSubsystem string) ClientWithMetrics
func (ClientWithMetrics) SubmitTx ¶ added in v1.11.1
func (c ClientWithMetrics) SubmitTx(ctx context.Context, rawTx string) (*proto.TXResponse, error)