Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultBootPeers = func(cfg *Config) error { defaultBotPeers := []string{} return cfg.Apply(BootPeers(defaultBotPeers)) }
DefaultConnectionManager creates a default connection manager
var DefaultConnectionManager = func(cfg *Config) error { mgr, err := connmgr.NewConnManager(100, 1000, connmgr.WithGracePeriod(time.Minute)) if err != nil { return err } return cfg.Apply(ConnectionManager(mgr)) }
DefaultConnectionManager creates a default connection manager
var DefaultDhtProtocolVersion = func(cfg *Config) error { defaultDhtProtocolVersion := "/kldr/kad/1.0" return cfg.Apply(DhtProtocolVersion(defaultDhtProtocolVersion)) }
DefaultConnectionManager creates a default connection manager
var DefaultListenPort = func(cfg *Config) error { port := 4001 return cfg.Apply(ListenPort(port)) }
DefaultListenAddrs configures libp2p to use default listen address.
var DefaultProtocolVersion = func(cfg *Config) error { defaultProtocolVersion := "/kldr/1.0" return cfg.Apply(ProtocolVersion(defaultProtocolVersion)) }
DefaultConnectionManager creates a default connection manager
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 ¶
func NewWithoutDefaults(ctx context.Context, privatekeyPath string, opts ...Option) (core.P2P, error)
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
func DhtProtocolVersion ¶ added in v0.0.24
BootPeers configures bootstrap nodes
func ListenPort ¶ added in v0.0.24
ListenAddrStrings configures libp2p to listen on the given (unparsed) addresses.
func ProtocolVersion ¶ added in v0.0.24
BootPeers configures bootstrap nodes