Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConnectionManager = func(cfg *Config) error { mgr, err := connmgr.NewConnManager(160, 192) if err != nil { return err } return cfg.Apply(ConnectionManager(mgr)) }
DefaultConnectionManager creates a default connection manager
var DefaultListenAddrs = func(cfg *Config) error { ip := "0.0.0.0" port := 80 return cfg.Apply(ListenAddrStrings(ip, port)) }
DefaultListenAddrs configures libp2p to use default listen address.
var DefaultWorkspace = func(cfg *Config) error { workspace, err := os.Getwd() if err != nil { return err } return cfg.Apply(Workspace(workspace)) }
DefaultListenAddrs configures libp2p to use default listen address.
Functions ¶
func New ¶
New constructs a new libp2p node with the given options, falling back on reasonable defaults. The defaults are:
- If no transport and listen addresses are provided, the node listens to the multiaddresses "/ip4/0.0.0.0/tcp/0" and "/ip6/::/tcp/0";
To stop/shutdown the returned p2p node, the user needs to cancel the passed context and call `Close` on the returned Host.
func NewWithoutDefaults ¶
NewWithoutDefaults constructs a new libp2p node with the given options but *without* falling back on reasonable defaults.
Warning: This function should not be considered a stable interface. We may choose to add required services at any time and, by using this function, you opt-out of any defaults we may provide.
Types ¶
type Option ¶
Option is a p2p config option that can be given to the p2p constructor
var FallbackDefaults Option = func(cfg *Config) error { for _, def := range defaults { if !def.fallback(cfg) { continue } if err := cfg.Apply(def.opt); err != nil { return err } } return nil }
FallbackDefaults applies default options to the libp2p node if and only if no other relevant options have been applied. will be appended to the options passed into New.
func ConnectionManager ¶
func ConnectionManager(connman connmgr.ConnManager) Option
ConnectionManager configures libp2p to use the given connection manager.
The current "standard" connection manager lives in github.com/libp2p/go-libp2p-connmgr. See https://pkg.go.dev/github.com/libp2p/go-libp2p-connmgr?utm_source=godoc#NewConnManager.
func ListenAddrStrings ¶
ListenAddrStrings configures libp2p to listen on the given (unparsed) addresses.
func ListenAddrs ¶
ListenAddrs configures libp2p to listen on the given addresses.