diamnetcore

package
v0.0.0-...-c9303cd Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package diamnetcore is a client library for communicating with an instance of diamnet-core using through the server's HTTP port.

Index

Examples

Constants

View Source
const SetCursorDone = "Done"

SetCursorDone is the success message returned by diamnet-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 diamnet-core.  If nil,
	// http.DefaultClient will be used.
	HTTP HTTP

	// URL of DiamNet Core server to connect.
	URL string
}

Client represents a client that is capable of communicating with a diamnet-core server using HTTP

func (*Client) Info

func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error)

Info calls the `info` command on the connected diamnet 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) SetCursor

func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) error

SetCursor calls the `setcursor` command on the connected diamnet core

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 diamnet core with the provided envelope

func (*Client) WaitForNetworkSync

func (c *Client) WaitForNetworkSync(ctx context.Context) error

WaitForNetworkSync continually polls the connected diamnet-core until it receives a response that indicated the node has synced with the network

type HTTP

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

HTTP represents the http client that a diamnetcore client uses to make http requests.

Jump to

Keyboard shortcuts

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