peer

package
v0.0.0-...-7e2f347 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: GPL-3.0, LGPL-3.0 Imports: 14 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 interface {
	// RequestAny synchronously sends request to the first connected peer that matches the specified minVersion in
	// random order.
	// A peer is considered a match if its version is greater than or equal to the specified minVersion
	// Returns errNoPeersMatchingVersion if no peer could be found matching specified version
	// and errRequestFailed if the request should be retried.
	RequestAny(minVersion *version.Application, request []byte) ([]byte, error)

	// Request synchronously sends request to the selected nodeID
	// Returns response bytes
	// Returns errRequestFailed if request should be retried
	Request(nodeID ids.NodeID, request []byte) ([]byte, error)

	// Gossip sends given gossip message to peers
	Gossip(gossip []byte) error
}

Client defines ability to send request / response through the Network

func NewClient

func NewClient(network Network) Client

NewClient returns Client for a given network

type Network

type Network interface {
	validators.Connector
	common.AppHandler

	// RequestAny synchronously sends request to the first connected peer that matches the specified minVersion in
	// random order.
	// A peer is considered a match if its version is greater than or equal to the specified minVersion
	// Returns an error if the request could not be sent to a peer with the desired [minVersion].
	RequestAny(minVersion *version.Application, message []byte, handler message.ResponseHandler) error

	// Request sends message to given nodeID, notifying handler when there's a response or timeout
	Request(nodeID ids.NodeID, message []byte, handler message.ResponseHandler) error

	// Gossip sends given gossip message to peers
	Gossip(gossip []byte) error

	// Shutdown stops all peer channel listeners and marks the node to have stopped
	// n.Start() can be called again but the peers will have to be reconnected
	// by calling OnPeerConnected for each peer
	Shutdown()

	// SetGossipHandler sets the provided gossip handler as the gossip handler
	SetGossipHandler(handler message.GossipHandler)

	// SetRequestHandler sets the provided request handler as the request handler
	SetRequestHandler(handler message.RequestHandler)

	// Size returns the size of the network in number of connected peers
	Size() uint32
}

func NewNetwork

func NewNetwork(appSender common.AppSender, codec codec.Manager, self ids.NodeID, maxActiveRequests int64) Network

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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