sync

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package sync provides Client and Server APIs that ensures robust network connectivity between all peers in the DKG. It supports cluster_definition verification, soft shutdown and reconnect on connection loss.

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 the client side of the sync protocol. It retries establishing a connection to a sync server, it sends period pings (including definition hash signatures), supports reestablishing on relay circuit recycling, and supports soft shutdown.

func NewClient

func NewClient(tcpNode host.Host, peer peer.ID, hashSig []byte) *Client

NewClient returns a new Client instance.

func (*Client) DisableReconnect added in v0.13.0

func (c *Client) DisableReconnect()

DisableReconnect disables shared reconnect state.

func (*Client) IsConnected added in v0.13.0

func (c *Client) IsConnected() bool

IsConnected returns if client is connected to the server or not.

func (*Client) Run added in v0.8.0

func (c *Client) Run(ctx context.Context) error

Run blocks while running the client-side sync protocol. It tries to reconnect if relay connection is dropped or connection is broken while in reconnect state. It returns nil after successful Shutdown.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

Shutdown triggers the Run goroutine to shut down gracefully and returns nil after it has returned. It should be called after client is connected and may only be called once.

type Server

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

Server implements the server side of the sync protocol. It accepts connections from clients, verifies definition hash signatures, and supports waiting for shutdown by all clients.

func NewServer

func NewServer(tcpNode host.Host, allCount int, defHash []byte) *Server

NewServer returns a new Server instance.

func (*Server) AwaitAllConnected

func (s *Server) AwaitAllConnected(ctx context.Context) error

AwaitAllConnected blocks until all peers have established a connection with this server or returns an error.

func (*Server) AwaitAllShutdown

func (s *Server) AwaitAllShutdown(ctx context.Context) error

AwaitAllShutdown blocks until all peers have successfully shutdown or returns an error. It may only be called after AwaitAllConnected.

func (*Server) Start added in v0.8.0

func (s *Server) Start(ctx context.Context)

Start registers sync protocol with the libp2p host.

Jump to

Keyboard shortcuts

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