Documentation ¶
Index ¶
- Constants
- Variables
- func AddrFilters(filters []string) func() (*ma.Filters, Libp2pOpts, error)
- func AddrsFactory(announce []string, appendAnnouce []string, noAnnounce []string) func() (opts Libp2pOpts, err error)
- func AutoNATService(throttle *config.AutoNATThrottleConfig) func() Libp2pOpts
- func BaseRouting(experimentalDHTClient bool) interface{}
- func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error)
- func ConstructDefaultRouting(peerID string, addrs []string, privKey string) ...
- func ConstructDelegatedRouting(routers config.Routers, methods config.Methods, peerID string, addrs []string, ...) ...
- func ContentRouting(in p2pOnlineContentRoutingIn) routing.ContentRouting
- func DiscoveryHandler(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) *discoveryHandler
- func FloodSub(pubsubOptions ...pubsub.Option) interface{}
- func ForceReachability(val *config.OptionalString) func() (opts Libp2pOpts, err error)
- func GossipSub(pubsubOptions ...pubsub.Option) interface{}
- func HolePunching(flag config.Flag, hasRelayClient bool) func() (opts Libp2pOpts, err error)
- func MaybeAutoRelay(staticRelays []string, cfgPeering config.Peering, enabled bool) fx.Option
- func NetLimit(mgr network.ResourceManager, scope string) (rcmgr.BaseLimit, error)
- func NetResetLimit(mgr network.ResourceManager, repo repo.Repo, scope string) (rcmgr.BaseLimit, error)
- func NetSetLimit(mgr network.ResourceManager, repo repo.Repo, scope string, ...) error
- func OfflineRouting(dstore ds.Datastore, validator record.Validator) p2pRouterOut
- func PNet(repo repo.Repo) (opts Libp2pOpts, fp PNetFingerprint, err error)
- func PNetChecker(repo repo.Repo, ph host.Host, lc fx.Lifecycle) error
- func Peerstore(lc fx.Lifecycle) (peerstore.Peerstore, error)
- func PstoreAddSelfKeys(id peer.ID, sk crypto.PrivKey, ps peerstore.Peerstore) error
- func PubsubRouter(mctx helpers.MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (p2pRouterOut, *namesys.PubsubValueStore, error)
- func RelayService(enable bool, relayOpts config.RelayService) func() (opts Libp2pOpts, err error)
- func RelayTransport(enableRelay bool) func() (opts Libp2pOpts, err error)
- func ResourceManager(cfg config.SwarmConfig) interface{}
- func Routing(in p2pOnlineRoutingIn) irouting.ProvideManyRouter
- func Security(enabled bool, tptConfig config.Transports) interface{}
- func SetupDiscovery(useMdns bool) func(helpers.MetricsCtx, fx.Lifecycle, host.Host, *discoveryHandler) error
- func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error)
- func StartListening(addresses []string) func(host host.Host) error
- func TopicDiscovery() interface{}
- func Transports(tptConfig config.Transports) interface{}
- func UserAgent() func() (opts Libp2pOpts, err error)
- type AddrInfoChan
- type HostOption
- type Libp2pOpts
- type NetStatOut
- type P2PHostIn
- type P2PHostOut
- type PNetFingerprint
- type Router
- type RoutingOption
Constants ¶
const NetLimitDefaultFilename = "limit.json"
const NetLimitTraceFilename = "rcmgr.json.gz"
Variables ¶
var ( DHTOption RoutingOption = constructDHTRouting(dht.ModeAuto) DHTClientOption = constructDHTRouting(dht.ModeClient) DHTServerOption = constructDHTRouting(dht.ModeServer) NilRouterOption = constructNilRouting )
var ErrNoResourceMgr = fmt.Errorf("missing ResourceMgr: make sure the daemon is running with Swarm.ResourceMgr.Enabled")
var NatPortMap = simpleOpt(libp2p.NATPortMap())
Functions ¶
func AddrFilters ¶
func AddrFilters(filters []string) func() (*ma.Filters, Libp2pOpts, error)
func AddrsFactory ¶
func AddrsFactory(announce []string, appendAnnouce []string, noAnnounce []string) func() (opts Libp2pOpts, err error)
func AutoNATService ¶
func AutoNATService(throttle *config.AutoNATThrottleConfig) func() Libp2pOpts
func BaseRouting ¶
func BaseRouting(experimentalDHTClient bool) interface{}
func ConnectionManager ¶
func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error)
func ConstructDefaultRouting ¶ added in v0.18.0
func ConstructDefaultRouting(peerID string, addrs []string, privKey string) func( ctx context.Context, host host.Host, dstore datastore.Batching, validator record.Validator, bootstrapPeers ...peer.AddrInfo, ) (routing.Routing, error)
ConstructDefaultRouting returns routers used when Routing.Type is unset or set to "auto"
func ConstructDelegatedRouting ¶ added in v0.16.0
func ConstructDelegatedRouting(routers config.Routers, methods config.Methods, peerID string, addrs []string, privKey string) func( ctx context.Context, host host.Host, dstore datastore.Batching, validator record.Validator, bootstrapPeers ...peer.AddrInfo, ) (routing.Routing, error)
ConstructDelegatedRouting is used when Routing.Type = "custom"
func ContentRouting ¶
func ContentRouting(in p2pOnlineContentRoutingIn) routing.ContentRouting
ContentRouting will get all routers that can do contentRouting and add them all together using a TieredRouter. It will be used for topic discovery.
func DiscoveryHandler ¶
func ForceReachability ¶
func ForceReachability(val *config.OptionalString) func() (opts Libp2pOpts, err error)
func HolePunching ¶
func HolePunching(flag config.Flag, hasRelayClient bool) func() (opts Libp2pOpts, err error)
func MaybeAutoRelay ¶ added in v0.16.0
func NetResetLimit ¶ added in v0.17.0
func NetResetLimit(mgr network.ResourceManager, repo repo.Repo, scope string) (rcmgr.BaseLimit, error)
NetResetLimit resets ResourceManager limits to defaults. The limits take effect immediately, and are also persisted to the repo config.
func NetSetLimit ¶
func NetSetLimit(mgr network.ResourceManager, repo repo.Repo, scope string, limit rcmgr.BaseLimit) error
NetSetLimit sets new ResourceManager limits for the given scope. The limits take effect immediately, and are also persisted to the repo config.
func OfflineRouting ¶
OfflineRouting provides a special Router to the routers list when we are creating a offline node.
func PNet ¶
func PNet(repo repo.Repo) (opts Libp2pOpts, fp PNetFingerprint, err error)
func PstoreAddSelfKeys ¶
func PubsubRouter ¶
func PubsubRouter(mctx helpers.MetricsCtx, lc fx.Lifecycle, in p2pPSRoutingIn) (p2pRouterOut, *namesys.PubsubValueStore, error)
func RelayService ¶
func RelayService(enable bool, relayOpts config.RelayService) func() (opts Libp2pOpts, err error)
func RelayTransport ¶
func RelayTransport(enableRelay bool) func() (opts Libp2pOpts, err error)
func ResourceManager ¶
func ResourceManager(cfg config.SwarmConfig) interface{}
func Routing ¶
func Routing(in p2pOnlineRoutingIn) irouting.ProvideManyRouter
Routing will get all routers obtained from different methods (delegated routers, pub-sub, and so on) and add them all together using a TieredRouter.
func Security ¶
func Security(enabled bool, tptConfig config.Transports) interface{}
func SetupDiscovery ¶
func SmuxTransport ¶
func SmuxTransport(tptConfig config.Transports) func() (opts Libp2pOpts, err error)
func TopicDiscovery ¶
func TopicDiscovery() interface{}
func Transports ¶
func Transports(tptConfig config.Transports) interface{}
func UserAgent ¶
func UserAgent() func() (opts Libp2pOpts, err error)
Types ¶
type AddrInfoChan ¶
type HostOption ¶
type HostOption func(id peer.ID, ps peerstore.Peerstore, options ...libp2p.Option) (host.Host, error)
var DefaultHostOption HostOption = constructPeerHost
type Libp2pOpts ¶
func BandwidthCounter ¶
func BandwidthCounter() (opts Libp2pOpts, reporter *metrics.BandwidthCounter)
func MultiaddrResolver ¶
func MultiaddrResolver(rslv *madns.Resolver) (opts Libp2pOpts, err error)
type NetStatOut ¶
type NetStatOut struct { System *rcmgr.BaseLimit `json:",omitempty"` Transient *rcmgr.BaseLimit `json:",omitempty"` Services map[string]rcmgr.BaseLimit `json:",omitempty"` Protocols map[string]rcmgr.BaseLimit `json:",omitempty"` Peers map[string]rcmgr.BaseLimit `json:",omitempty"` }
func NetLimitAll ¶ added in v0.17.0
func NetLimitAll(mgr network.ResourceManager) (*NetStatOut, error)
func NetStat ¶
func NetStat(mgr network.ResourceManager, scope string, percentage int) (NetStatOut, error)
type P2PHostOut ¶
func Host ¶
func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHostOut, err error)
type PNetFingerprint ¶
type PNetFingerprint []byte