net

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connectedness

type Connectedness int

Connectedness signals the capacity for a connection with a given node.

const (
	// Unspecified means unable to determine connectedness.
	Unspecified Connectedness = iota

	// NotConnected means no connection to peer, and no extra information (default).
	NotConnected

	// Connected means has an open, live connection to peer.
	Connected

	// CanConnect means recently connected to peer, terminated gracefully.
	CanConnect

	// CannotConnect means recently attempted connecting but failed to connect.
	CannotConnect

	// Error means there was an error determining connectedness.
	Error
)

func (Connectedness) String

func (s Connectedness) String() string

type Module

type Module interface {
	// ListenAddr returns listener address info for the local node.
	ListenAddr(context.Context) (peer.AddrInfo, error)
	// Peers returns a list of peers.
	Peers(context.Context) ([]PeerInfo, error)
	// FindPeer finds a peer by peer id
	FindPeer(context.Context, peer.ID) (PeerInfo, error)
	// ConnectPeer connects to a peer.
	ConnectPeer(context.Context, peer.AddrInfo) error
	// DisconnectPeer disconnects from a peer.
	DisconnectPeer(context.Context, peer.ID) error
	// Connectedness returns the connection status to a peer.
	Connectedness(context.Context, peer.ID) (Connectedness, error)
}

Module defines the net API.

type PeerInfo

type PeerInfo struct {
	AddrInfo peer.AddrInfo
	Location *iplocation.Location
}

PeerInfo provides address info and location info about a peer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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