sync

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 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) AwaitConnected

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

AwaitConnected blocks until the connection with the server has been established or returns a context error.

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 returns an error if the context is closed or if an established connection is dropped. 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 AwaitConnected 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