net

package
v0.0.1-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 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 (
	// NotConnected means no connection to peer, and no extra information (default)
	NotConnected Connectedness = iota

	// 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

	// Unknown means unable to determine connectedness
	Unknown

	// 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