relay

package
v0.0.0-...-69f1810 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package relay provides an external interface for a validating node. The relay opens a port for actions gateway, another port that listen to requests to receive block events and a third port for administrative purposes for the node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitForOutgoingSyncRequest

func WaitForOutgoingSyncRequest(conn *socket.SignedConnection, outgoing chan SyncRequest, drop chan crypto.Token, action chan []byte, topology chan *socket.SignedConnection)

WaitForOutgoingSyncRequest reads a sync request from a connection and sends it to the sync request channel. If it is not a valid request, if closes the conection and returns without sending anything to outgoing channel.

func WaitForProtocolActions

func WaitForProtocolActions(conn *socket.SignedConnection, terminate chan crypto.Token, action chan []byte)

WaitForProtocolActions reads proposed actions from a connection and sends them to the action channel. If the connection is terminated, it sends the connection token to the terminate channel.

Types

type Config

type Config struct {
	GatewayPort       int
	BlockListenerPort int
	Firewall          *Firewall
	Credentials       crypto.PrivateKey
	Hostname          string
}

Config defines the configuration for a relay node. The firewall defines the authorized connections for the gateway and the block listener. The credentials should be the private key of the validating node. Hostname is "localhost" or empty for internet connections. For test it can be any string.

type Firewall

type Firewall struct {
	AcceptGateway       *socket.AcceptValidConnections
	AcceptBlockListener *socket.AcceptValidConnections
}

Firewall defines the authorized connections for the gateway and the block listener.

func NewFireWall

func NewFireWall(authorizedGateway []crypto.Token, autorizedBlockListener []crypto.Token, openGateway, opeanBlockListener bool) *Firewall

NewFireWall returns a new firewall with the authorized gateway and block listener tokens.

type Node

type Node struct {
	ActionGateway   chan []byte                   // Sends actions to swell engine
	BlockEvents     chan []byte                   // receive block events from swell engine
	SyncRequest     chan SyncRequest              // sends sync requests to swell engine
	TopologyRequest chan *socket.SignedConnection // sends request for topology
	Statement       chan []byte
	// contains filtered or unexported fields
}

Node defines the external interface for a validating node. ActionGateway channel shoud be read by the validating node to receive proposed actions. BlockEvents channel should be write by the validating node to broadcast block events. SyncRequest channel should be read by the validating node to receive requests for state sync and recenet blocks sync.

func Run

func Run(ctx context.Context, cfg *Config) (*Node, error)

Run starts a relay network. It returns a Node and an error. On cancelation of the context, the entire relay network is graciously shutdown.

func (*Node) Status

func (n *Node) Status() string

type Shutdowner

type Shutdowner interface {
	Shutdown()
}

type SyncRequest

type SyncRequest struct {
	Epoch uint64
	State bool
	Conn  *socket.CachedConnection
}

SyncRequest defines a request for state sync and recent blocks sync. Epoch is the first epoch for which the requester needs a block. State is true if the requester needs a state sync.

Jump to

Keyboard shortcuts

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