rpc

package
v4.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingParts = errors.Errorf("need more parts")

Functions

func GenerateRandomID

func GenerateRandomID(net cMixClient) (*id.ID, error)

Types

type QueryResponse

type QueryResponse struct {
	Message []byte `json:"message"`
}

type Request

type Request struct {
	// contains filtered or unexported fields
}

type Response

type Response interface {
	// Callback calls success or error function if/when the
	// response is received. Meant to be very similar to Promise/async
	// found in other languages.
	// RPC will call respFn 3 times: sent, round finished, and
	// response received.
	Callback(respFn func(response []byte), errFn func(err error)) Response

	// Wait waits until the response is complete returns the final
	// response bytes
	Wait() []byte
}

Response interface for RPC responses from the Send function. Provides for the ability to call a callback on error or success or to listen on the channels directly.

func Send

func Send(net cMixClient, serverID *id.ID, serverKey nike.PublicKey,
	request []byte, params cmix.CMIXParams) Response

type RoundResults

type RoundResults struct {
	Success  bool                          `json:"success"`
	TimedOut bool                          `json:"timedOut"`
	Results  map[id.Round]cmix.RoundResult `json:"results"`
}

type SentMessage

type SentMessage struct {
	Round        rounds.Round   `json:"round"`
	EphemeralIDs []ephemeral.Id `json:"ephemeralIDs"`
}

type Server

type Server interface {
	// Start listening on the server's cMix Identity
	Start()
	// Stop listening on the server's cMix Identity
	// Note: if you want to stop all network traffic, do
	// so with the cMix network client.
	Stop()
	// SetCallback allows you to change the callback after
	// initialization. This must be called before starting
	// the server.
	SetCallback(cbFn func(id *id.ID, request []byte) []byte)
}

Server is the interface for the RPC server, users should add a callback then start listening for RPC requests.

func NewServer

func NewServer(net cMixClient,
	callback func(id *id.ID, request []byte) []byte,
	receptionID *id.ID,
	privateKey nike.PrivateKey) Server

Jump to

Keyboard shortcuts

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