swarm

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyOpen = errors.New("Error: Connection to this peer already open.")

ErrAlreadyOpen signals that a connection to a peer is already open.

Functions

This section is empty.

Types

type ListenErr

type ListenErr struct {
	Errors []error
}

ListenErr contains a set of errors mapping to each of the swarms addresses. Used to return multiple errors, as in listen.

func (*ListenErr) Error

func (e *ListenErr) Error() string

type Swarm

type Swarm struct {

	// Swarm includes a Pipe object.
	*msg.Pipe
	// contains filtered or unexported fields
}

Swarm is a connection muxer, allowing connections to other peers to be opened and closed, while still using the same Chan for all communication. The Chan sends/receives Messages, which note the destination or source Peer.

func NewSwarm

func NewSwarm(ctx context.Context, local *peer.Peer, ps peer.Peerstore) (*Swarm, error)

NewSwarm constructs a Swarm, with a Chan.

func (*Swarm) Close

func (s *Swarm) Close() error

Close stops a swarm.

func (*Swarm) CloseConnection

func (s *Swarm) CloseConnection(p *peer.Peer) error

CloseConnection removes a given peer from swarm + closes the connection

func (*Swarm) Dial

func (s *Swarm) Dial(peer *peer.Peer) (*conn.Conn, error)

Dial connects to a peer.

The idea is that the client of Swarm does not need to know what network the connection will happen over. Swarm can use whichever it choses. This allows us to use various transport protocols, do NAT traversal/relay, etc. to achive connection.

For now, Dial uses only TCP. This will be extended.

func (*Swarm) DialAddr

func (s *Swarm) DialAddr(addr *ma.Multiaddr) (*conn.Conn, error)

DialAddr is for connecting to a peer when you know their addr but not their ID. Should only be used when sure that not connected to peer in question TODO(jbenet) merge with Dial? need way to patch back.

func (*Swarm) Error

func (s *Swarm) Error(e error)

func (*Swarm) GetConnection

func (s *Swarm) GetConnection(pid peer.ID) *conn.Conn

GetConnection returns the connection in the swarm to given peer.ID

func (*Swarm) GetErrChan

func (s *Swarm) GetErrChan() chan error

GetErrChan returns the errors chan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳