Documentation
¶
Index ¶
- type BatchHTTP
- func (b *BatchHTTP) Clear() int
- func (b *BatchHTTP) Count() int
- func (c BatchHTTP) GenesisChunked(ctx context.Context, id uint) (*ctypes.ResultGenesisChunk, error)
- func (c BatchHTTP) Health(ctx context.Context) (*ctypes.ResultHealth, error)
- func (c BatchHTTP) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)
- func (c BatchHTTP) QueryRequest(ctx context.Context, hash string) (*ctypes.ResultDvsRequest, error)
- func (c BatchHTTP) RequestDVS(ctx context.Context, data []byte, height int64, chainid int64, ...) (*ctypes.ResultRequest, error)
- func (c BatchHTTP) RequestDVSAsync(ctx context.Context, data []byte, height int64, chainid int64, ...) (*ctypes.ResultRequestDvsAsync, error)
- func (c BatchHTTP) SearchRequest(ctx context.Context, query string, pagePtr, perPagePtr *int) (*ctypes.ResultDvsRequestSearch, error)
- func (b *BatchHTTP) Send(ctx context.Context) ([]interface{}, error)
- type HTTP
- func (c HTTP) GenesisChunked(ctx context.Context, id uint) (*ctypes.ResultGenesisChunk, error)
- func (c HTTP) Health(ctx context.Context) (*ctypes.ResultHealth, error)
- func (c HTTP) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)
- func (c *HTTP) NewBatch() *BatchHTTP
- func (c HTTP) QueryRequest(ctx context.Context, hash string) (*ctypes.ResultDvsRequest, error)
- func (c *HTTP) Remote() string
- func (c HTTP) RequestDVS(ctx context.Context, data []byte, height int64, chainid int64, ...) (*ctypes.ResultRequest, error)
- func (c HTTP) RequestDVSAsync(ctx context.Context, data []byte, height int64, chainid int64, ...) (*ctypes.ResultRequestDvsAsync, error)
- func (c HTTP) SearchRequest(ctx context.Context, query string, pagePtr, perPagePtr *int) (*ctypes.ResultDvsRequestSearch, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchHTTP ¶
type BatchHTTP struct {
// contains filtered or unexported fields
}
BatchHTTP provides the same interface as `HTTP`, but allows for batching of requests (as per https://www.jsonrpc.org/specification#batch). Do not instantiate directly - rather use the HTTP.NewBatch() method to create an instance of this struct.
Batching of HTTP requests is thread-safe in the sense that multiple goroutines can each create their own batches and send them using the same HTTP client. Multiple goroutines could also enqueue transactions in a single batch, but ordering of transactions in the batch cannot be guaranteed in such an example.
func (*BatchHTTP) Clear ¶
Clear will empty out this batch of requests and return the number of requests that were cleared out.
func (BatchHTTP) GenesisChunked ¶
func (BatchHTTP) Health ¶
func (c BatchHTTP) Health(ctx context.Context) (*ctypes.ResultHealth, error)
func (BatchHTTP) NetInfo ¶
func (c BatchHTTP) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)
func (BatchHTTP) QueryRequest ¶
func (BatchHTTP) RequestDVS ¶
func (BatchHTTP) RequestDVSAsync ¶
func (BatchHTTP) SearchRequest ¶ added in v0.3.0
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is a Client implementation that communicates with a PellDVS node over JSON RPC and WebSockets.
This is the main implementation you probably want to use in production code. There are other implementations when calling the PellDVS node in-process (Local), or when you want to mock out the server for test code (mock).
You can subscribe for any event published by PellDVS using Subscribe method. Note delivery is best-effort. If you don't read events fast enough or network is slow, PellDVS might cancel the subscription. The client will attempt to resubscribe (you don't need to do anything). It will keep trying every second indefinitely until successful.
Request batching is available for JSON RPC requests over HTTP, which conforms to the JSON RPC specification (https://www.jsonrpc.org/specification#batch). See the example for more details.
Example:
c, err := New("http://192.168.1.10:26657", "/websocket") if err != nil { // handle error } // call Start/Stop if you're subscribing to events err = c.Start() if err != nil { // handle error } defer c.Stop() res, err := c.Status() if err != nil { // handle error } // handle result
func New ¶
New takes a remote endpoint in the form <protocol>://<host>:<port> and the websocket path (which always seems to be "/websocket") An error is returned on invalid remote. The function panics when remote is nil.
func NewWithClient ¶
NewWithClient allows for setting a custom http client (See New). An error is returned on invalid remote. The function panics when remote is nil.
func NewWithTimeout ¶
Create timeout enabled http client