rpc

package
v0.0.0-...-f9ec29b Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a JSON RPC 2.0 client implementation over WebSockets. It can be used to communicate with a 0x Mesh node and add orders.

func NewClient

func NewClient(addr string) (*Client, error)

NewClient creates and returns a new client. addr is the address of the server (i.e. a 0x Mesh node) to dial.

func (*Client) AddOrder

func (c *Client) AddOrder(order *zeroex.SignedOrder) (common.Hash, error)

AddOrder adds the order to the 0x Mesh node and broadcasts it throughout the 0x Mesh network.

func (*Client) AddPeer

func (c *Client) AddPeer(peerInfo peerstore.PeerInfo) error

AddPeer adds the peer to the node's list of peers. The node will attempt to connect to this new peer and return an error if it cannot.

type RPCHandler

type RPCHandler interface {
	// AddOrder is called when the client sends an AddOrder request.
	AddOrder(order *zeroex.SignedOrder) error
	// AddPeer is called when the client sends an AddPeer request.
	AddPeer(peerInfo peerstore.PeerInfo) error
}

RPCHandler is used to respond to incoming requests from the client.

type Server

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

Server is a JSON RPC 2.0 server implementation over WebSockets. It accepts requests from a client for adding orders to the 0x Mesh network.

func NewServer

func NewServer(addr string, rpcHandler RPCHandler) (*Server, error)

NewServer creates and returns a new server which will listen for new connections on the given addr and use the rpcHandler to handle incoming requests.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the address the server is listening on or nil if it has not yet started listening.

func (*Server) Close

func (s *Server) Close() error

Close closes the listener and stops it from accepting new connections or responding to any new requests.

func (*Server) Listen

func (s *Server) Listen() error

Listen causes the server to listen for new connections. You can call Close to stop listening. Listen blocks until there is an error.

Jump to

Keyboard shortcuts

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