net

package
v0.0.0-...-2540013 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SwapProtocolID = protocol.ID("/atomicswap/1.0.0")
	FloodSubID     = protocol.ID("/atomicfloodsub/1.0.0")
)

These protocol IDs are used to route messages. We could use the defaults but then other apps which use the defaults can connect to us even if we can't handle their messages. So we'll use unique protocol strings to make sure we are segregated from other apps.

Variables

View Source
var DefaultBootstrapConfig = BootstrapConfig{
	MinPeerThreshold:  2,
	Period:            30 * time.Second,
	ConnectionTimeout: (30 * time.Second) / 3,
}

DefaultBootstrapConfig specifies default sane parameters for bootstrapping.

View Source
var ErrNotEnoughBootstrapPeers = errors.New("not enough bootstrap peers to bootstrap")

ErrNotEnoughBootstrapPeers signals that we do not have enough bootstrap peers to bootstrap correctly.

Functions

func Bootstrap

func Bootstrap(dht *routing.IpfsDHT, peerHost host.Host, cfg BootstrapConfig) error

Bootstrap kicks off the dht bootstrapping. This function will periodically check the number of open connections and -- if there are too few -- initiate connections to well-known bootstrap peers.

func NewPeerHost

func NewPeerHost(port int, repo *repo.Repo) (host.Host, error)

Types

type BootstrapConfig

type BootstrapConfig struct {

	// MinPeerThreshold governs whether to bootstrap more connections. If the
	// node has less open connections than this number, it will open connections
	// to the bootstrap nodes. From there, the routing system should be able
	// to use the connections to the bootstrap nodes to connect to even more
	// peers. Routing systems like the libp2p-kad-dht do so in their own Bootstrap
	// process, which issues random queries to find more peers.
	MinPeerThreshold int

	// Period governs the periodic interval at which the node will
	// attempt to bootstrap. The bootstrap process is not very expensive, so
	// this threshold can afford to be small (<=30s).
	Period time.Duration

	// ConnectionTimeout determines how long to wait for a bootstrap
	// connection attempt before cancelling it.
	ConnectionTimeout time.Duration

	// BootstrapPeers is a function that returns a set of bootstrap peers
	// for the bootstrap process to use. This makes it possible for clients
	// to control the peers the process uses at any moment.
	BootstrapPeers func() []pstore.PeerInfo
}

func BootstrapConfigWithPeers

func BootstrapConfigWithPeers(pis []pstore.PeerInfo) BootstrapConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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