transport

package
v0.0.0-...-707b10e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is returned when an expected incoming connection was not received in time.
	ErrTimeout = errors.New("accept timeout")
	// ErrClosed means that the transport was shut down before a response could be received.
	ErrClosed = errors.New("transport closed")
	// ErrInvalidHandshake is returned when no correct handshake could be established.
	ErrInvalidHandshake = errors.New("invalid handshake")
	// ErrNoGossip means that the given peer does not support the gossip service.
	ErrNoGossip = errors.New("peer does not have a gossip service")
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	net.Conn
	// contains filtered or unexported fields
}

Connection represents a network connection to a neighbor peer.

func (*Connection) Peer

func (c *Connection) Peer() *peer.Peer

Peer returns the peer associated with that connection.

type TCP

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

TCP establishes verified incoming and outgoing TCP connections to other peers.

func Listen

func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error)

Listen creates the object and starts listening for incoming connections.

func (*TCP) AcceptPeer

func (t *TCP) AcceptPeer(p *peer.Peer) (*Connection, error)

AcceptPeer awaits an incoming connection from the given peer. If the peer does not establish the connection or the handshake fails, an error is returned.

func (*TCP) Close

func (t *TCP) Close()

Close stops listening on the gossip address.

func (*TCP) DialPeer

func (t *TCP) DialPeer(p *peer.Peer) (*Connection, error)

DialPeer establishes a gossip connection to the given peer. If the peer does not accept the connection or the handshake fails, an error is returned.

func (*TCP) LocalAddr

func (t *TCP) LocalAddr() net.Addr

LocalAddr returns the listener's network address,

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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