libp2p

package
v0.12.0-rc Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 42 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DefaultConnMgrHighWater is the default value for the connection managers
	// 'high water' mark
	DefaultConnMgrHighWater = 900

	// DefaultConnMgrLowWater is the default value for the connection managers 'low
	// water' mark
	DefaultConnMgrLowWater = 600

	// DefaultConnMgrGracePeriod is the default value for the connection managers
	// grace period
	DefaultConnMgrGracePeriod = time.Second * 20
)

Defaults from ipfs

View Source
const (
	// StakeCheckTick is the amount of time between periodic checks for
	// minimum stake for all peers connected to this one.
	StakeCheckTick = time.Minute * 1
	// BootstrapCheckPeriod is the amount of time between periodic checks
	// for ensuring we are connected to an appropriate number of bootstrap
	// peers.
	BootstrapCheckPeriod = 10 * time.Second
)

watchtower constants

Variables

This section is empty.

Functions

func Connect

func Connect(
	ctx context.Context,
	config Config,
	staticKey *key.NetworkPrivate,
	stakeMonitor chain.StakeMonitor,
	ticker *retransmission.Ticker,
	options ...ConnectOption,
) (net.Provider, error)

Connect connects to a libp2p network based on the provided config. The connection is managed in part by the passed context, and provides access to the functionality specified in the net.Provider interface.

An error is returned if any part of the connection or bootstrap process fails.

Types

type Config

type Config struct {
	Peers              []string
	Port               int
	AnnouncedAddresses []string
}

Config defines the configuration for the libp2p network provider.

type ConnectOption

type ConnectOption func(options *ConnectOptions)

ConnectOption allows to set an options used by libp2p.

func WithBootstrapMinPeerThreshold

func WithBootstrapMinPeerThreshold(threshold int) ConnectOption

WithBootstrapMinPeerThreshold set a minimal peer threshold for bootstrap process.

func WithRoutingTableRefreshPeriod

func WithRoutingTableRefreshPeriod(period time.Duration) ConnectOption

WithRoutingTableRefreshPeriod set a refresh period of the routing table.

type ConnectOptions

type ConnectOptions struct {
	RoutingTableRefreshPeriod time.Duration
	BootstrapMinPeerThreshold int
}

ConnectOptions allows to set various options used by libp2p.

Jump to

Keyboard shortcuts

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