sync

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: GPL-3.0 Imports: 13 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

View Source
const (
	MsgSize    = 128
	InvalidSig = "Invalid Signature"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, tcpNode host.Host, server p2p.Peer, hashSig []byte, onFailure func()) Client

NewClient starts a goroutine that establishes a long lived connection to a p2p server and returns a new Client instance. TODO(dhruv): call onFailure on permanent failure.

func (*Client) AwaitConnected

func (c *Client) AwaitConnected() error

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

func (*Client) Shutdown

func (*Client) Shutdown() error

Shutdown sends a shutdown message to the server indicating it has successfully completed. It closes the connection and returns after receiving the subsequent MsgSyncResponse. It may only be called after AwaitConnected.

type Server

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

func NewServer

func NewServer(ctx context.Context, tcpNode host.Host, peers []p2p.Peer, defHash []byte, onFailure func()) *Server

NewServer registers a Stream Handler and returns a new Server instance.

func (*Server) AwaitAllConnected

func (*Server) AwaitAllConnected() error

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

func (*Server) AwaitAllShutdown

func (*Server) AwaitAllShutdown() error

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

Jump to

Keyboard shortcuts

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