Source File
libp2p.go
Belonging Package
github.com/libp2p/go-libp2p
package libp2pimport ()// Config describes a set of settings for a libp2p node.type Config = config.Config// Option is a libp2p config option that can be given to the libp2p constructor// (`libp2p.New`).type Option = config.Option// ChainOptions chains multiple options into a single option.func ( ...Option) Option {return func( *Config) error {for , := range {if == nil {continue}if := (); != nil {return}}return nil}}// 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";//// - If no transport options are provided, the node uses TCP, websocket and QUIC// transport protocols;//// - If no multiplexer configuration is provided, the node is configured by// default to use yamux;//// - If no security transport is provided, the host uses the go-libp2p's noise// and/or tls encrypted transport to encrypt all traffic;//// - If no peer identity is provided, it generates a random Ed25519 key-pair// and derives a new identity from it;//// - If no peerstore is provided, the host is initialized with an empty// peerstore.//// To stop/shutdown the returned libp2p node, the user needs to call `Close` on the returned Host.func ( ...Option) (host.Host, error) {return NewWithoutDefaults(append(, FallbackDefaults)...)}// 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.func ( ...Option) (host.Host, error) {var Configif := .Apply(...); != nil {return nil,}return .NewNode()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |