Documentation ¶
Index ¶
- func DefaultCreateNodeFunc(logger zerolog.Logger, host host.Host, pCache p2p.ProtocolPeerCache, ...) p2p.LibP2PNode
- func DefaultLibP2PHost(address string, key fcrypto.PrivateKey, options ...config.Option) (host.Host, error)
- func DefaultLibP2PNodeFactory(log zerolog.Logger, address string, flowKey fcrypto.PrivateKey, ...) p2p.LibP2PFactoryFunc
- func DefaultNodeBuilder(log zerolog.Logger, address string, flowKey fcrypto.PrivateKey, ...) (p2p.NodeBuilder, error)
- type ConnectionGaterConfig
- type CreateNodeFunc
- type GossipSubAdapterConfigFunc
- type GossipSubConfig
- type GossipSubFactoryFunc
- type LibP2PFactoryFunc
- type LibP2PNodeBuilder
- func (builder *LibP2PNodeBuilder) Build() (p2p.LibP2PNode, error)
- func (builder *LibP2PNodeBuilder) EnableGossipSubPeerScoring(provider module.IdentityProvider, config *p2p.PeerScoringConfig) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetBasicResolver(br madns.BasicResolver) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetConnectionGater(gater connmgr.ConnectionGater) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetConnectionManager(manager connmgr.ConnManager) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetCreateNode(f p2p.CreateNodeFunc) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetGossipSubFactory(gf p2p.GossipSubFactoryFunc, cf p2p.GossipSubAdapterConfigFunc) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetGossipSubRPCInspectors(inspectors ...p2p.GossipSubRPCInspector) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetGossipSubScoreTracerInterval(interval time.Duration) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetGossipSubTracer(tracer p2p.PubSubTracer) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetPeerManagerOptions(connectionPruning bool, updateInterval time.Duration) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetRateLimiterDistributor(distributor p2p.UnicastRateLimiterDistributor) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetResourceManager(manager network.ResourceManager) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetRoutingSystem(f func(context.Context, host.Host) (routing.Routing, error)) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetStreamCreationRetryInterval(createStreamRetryInterval time.Duration) p2p.NodeBuilder
- func (builder *LibP2PNodeBuilder) SetSubscriptionFilter(filter pubsub.SubscriptionFilter) p2p.NodeBuilder
- type PeerManagerConfig
- type ResourceManagerConfig
- type UnicastConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCreateNodeFunc ¶ added in v0.29.0
func DefaultCreateNodeFunc(logger zerolog.Logger, host host.Host, pCache p2p.ProtocolPeerCache, peerManager p2p.PeerManager) p2p.LibP2PNode
DefaultCreateNodeFunc returns new libP2P node.
func DefaultLibP2PHost ¶
func DefaultLibP2PHost(address string, key fcrypto.PrivateKey, options ...config.Option) (host.Host, error)
DefaultLibP2PHost returns a libp2p host initialized to listen on the given address and using the given private key and customized with options
func DefaultLibP2PNodeFactory ¶
func DefaultLibP2PNodeFactory(log zerolog.Logger, address string, flowKey fcrypto.PrivateKey, sporkId flow.Identifier, idProvider module.IdentityProvider, metrics module.NetworkMetrics, resolver madns.BasicResolver, role string, connGaterCfg *ConnectionGaterConfig, peerManagerCfg *PeerManagerConfig, gossipCfg *GossipSubConfig, rCfg *ResourceManagerConfig, uniCfg *UnicastConfig, ) p2p.LibP2PFactoryFunc
DefaultLibP2PNodeFactory returns a LibP2PFactoryFunc which generates the libp2p host initialized with the default options for the host, the pubsub and the ping service.
func DefaultNodeBuilder ¶ added in v0.29.0
func DefaultNodeBuilder(log zerolog.Logger, address string, flowKey fcrypto.PrivateKey, sporkId flow.Identifier, idProvider module.IdentityProvider, metrics module.LibP2PMetrics, resolver madns.BasicResolver, role string, connGaterCfg *ConnectionGaterConfig, peerManagerCfg *PeerManagerConfig, gossipCfg *GossipSubConfig, rCfg *ResourceManagerConfig, uniCfg *UnicastConfig) (p2p.NodeBuilder, error)
DefaultNodeBuilder returns a node builder.
Types ¶
type ConnectionGaterConfig ¶ added in v0.30.0
type ConnectionGaterConfig struct { // InterceptPeerDialFilters list of peer filters used to filter peers on outgoing connections in the InterceptPeerDial callback. InterceptPeerDialFilters []p2p.PeerFilter // InterceptSecuredFilters list of peer filters used to filter peers and accept or reject inbound connections in InterceptSecured callback. InterceptSecuredFilters []p2p.PeerFilter }
ConnectionGaterConfig configuration parameters for the connection gater.
type CreateNodeFunc ¶ added in v0.29.0
type CreateNodeFunc func(logger zerolog.Logger, host host.Host, pCache *p2pnode.ProtocolPeerCache, peerManager *connection.PeerManager) p2p.LibP2PNode
type GossipSubAdapterConfigFunc ¶ added in v0.29.0
type GossipSubAdapterConfigFunc func(*p2p.BasePubSubAdapterConfig) p2p.PubSubAdapterConfig
type GossipSubConfig ¶ added in v0.30.0
type GossipSubConfig struct { // LocalMeshLogInterval is the interval at which the local mesh is logged. LocalMeshLogInterval time.Duration // ScoreTracerInterval is the interval at which the score tracer logs the peer scores. ScoreTracerInterval time.Duration // PeerScoring is whether to enable GossipSub peer scoring. PeerScoring bool // RPCInspectors gossipsub RPC control message inspectors RPCInspectors []p2p.GossipSubRPCInspector }
GossipSubConfig is the configuration for the GossipSub pubsub implementation.
func DefaultGossipSubConfig ¶ added in v0.30.0
func DefaultGossipSubConfig() *GossipSubConfig
DefaultGossipSubConfig returns the default configuration for the gossipsub protocol.
type GossipSubFactoryFunc ¶ added in v0.29.0
type LibP2PFactoryFunc ¶
type LibP2PFactoryFunc func() (p2p.LibP2PNode, error)
LibP2PFactoryFunc is a factory function type for generating libp2p Node instances.
type LibP2PNodeBuilder ¶
type LibP2PNodeBuilder struct {
// contains filtered or unexported fields
}
func NewNodeBuilder ¶
func NewNodeBuilder(logger zerolog.Logger, metrics module.LibP2PMetrics, addr string, networkKey fcrypto.PrivateKey, sporkID flow.Identifier, rCfg *ResourceManagerConfig) *LibP2PNodeBuilder
func (*LibP2PNodeBuilder) Build ¶
func (builder *LibP2PNodeBuilder) Build() (p2p.LibP2PNode, error)
Build creates a new libp2p node using the configured options.
func (*LibP2PNodeBuilder) EnableGossipSubPeerScoring ¶
func (builder *LibP2PNodeBuilder) EnableGossipSubPeerScoring(provider module.IdentityProvider, config *p2p.PeerScoringConfig) p2p.NodeBuilder
EnableGossipSubPeerScoring enables peer scoring for the GossipSub pubsub system. Arguments: - module.IdentityProvider: the identity provider for the node (must be set before calling this method). - *PeerScoringConfig: the peer scoring configuration for the GossipSub pubsub system. If nil, the default configuration is used.
func (*LibP2PNodeBuilder) SetBasicResolver ¶
func (builder *LibP2PNodeBuilder) SetBasicResolver(br madns.BasicResolver) p2p.NodeBuilder
SetBasicResolver sets the DNS resolver for the node.
func (*LibP2PNodeBuilder) SetConnectionGater ¶
func (builder *LibP2PNodeBuilder) SetConnectionGater(gater connmgr.ConnectionGater) p2p.NodeBuilder
SetConnectionGater sets the connection gater for the node.
func (*LibP2PNodeBuilder) SetConnectionManager ¶
func (builder *LibP2PNodeBuilder) SetConnectionManager(manager connmgr.ConnManager) p2p.NodeBuilder
SetConnectionManager sets the connection manager for the node.
func (*LibP2PNodeBuilder) SetCreateNode ¶ added in v0.29.0
func (builder *LibP2PNodeBuilder) SetCreateNode(f p2p.CreateNodeFunc) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetGossipSubFactory ¶ added in v0.29.0
func (builder *LibP2PNodeBuilder) SetGossipSubFactory(gf p2p.GossipSubFactoryFunc, cf p2p.GossipSubAdapterConfigFunc) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetGossipSubRPCInspectors ¶ added in v0.30.0
func (builder *LibP2PNodeBuilder) SetGossipSubRPCInspectors(inspectors ...p2p.GossipSubRPCInspector) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetGossipSubScoreTracerInterval ¶ added in v0.30.0
func (builder *LibP2PNodeBuilder) SetGossipSubScoreTracerInterval(interval time.Duration) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetGossipSubTracer ¶ added in v0.30.0
func (builder *LibP2PNodeBuilder) SetGossipSubTracer(tracer p2p.PubSubTracer) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetPeerManagerOptions ¶
func (builder *LibP2PNodeBuilder) SetPeerManagerOptions(connectionPruning bool, updateInterval time.Duration) p2p.NodeBuilder
SetPeerManagerOptions sets the peer manager options.
func (*LibP2PNodeBuilder) SetRateLimiterDistributor ¶ added in v0.30.0
func (builder *LibP2PNodeBuilder) SetRateLimiterDistributor(distributor p2p.UnicastRateLimiterDistributor) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetResourceManager ¶
func (builder *LibP2PNodeBuilder) SetResourceManager(manager network.ResourceManager) p2p.NodeBuilder
SetResourceManager sets the resource manager for the node.
func (*LibP2PNodeBuilder) SetRoutingSystem ¶
func (builder *LibP2PNodeBuilder) SetRoutingSystem(f func(context.Context, host.Host) (routing.Routing, error)) p2p.NodeBuilder
SetRoutingSystem sets the routing system factory function.
func (*LibP2PNodeBuilder) SetStreamCreationRetryInterval ¶ added in v0.30.0
func (builder *LibP2PNodeBuilder) SetStreamCreationRetryInterval(createStreamRetryInterval time.Duration) p2p.NodeBuilder
func (*LibP2PNodeBuilder) SetSubscriptionFilter ¶
func (builder *LibP2PNodeBuilder) SetSubscriptionFilter(filter pubsub.SubscriptionFilter) p2p.NodeBuilder
SetSubscriptionFilter sets the pubsub subscription filter for the node.
type PeerManagerConfig ¶ added in v0.30.0
type PeerManagerConfig struct { // ConnectionPruning enables connection pruning in the connection manager. ConnectionPruning bool // UpdateInterval interval used by the libp2p node peer manager component to periodically request peer updates. UpdateInterval time.Duration }
PeerManagerConfig configuration parameters for the peer manager.
type ResourceManagerConfig ¶ added in v0.29.0
type ResourceManagerConfig struct { MemoryLimitRatio float64 // maximum allowed fraction of memory to be allocated by the libp2p resources in (0,1] FileDescriptorsRatio float64 // maximum allowed fraction of file descriptors to be allocated by the libp2p resources in (0,1] PeerBaseLimitConnsInbound int // the maximum amount of allowed inbound connections per peer }
ResourceManagerConfig returns the resource manager configuration for the libp2p node. The resource manager is used to limit the number of open connections and streams (as well as any other resources used by libp2p) for each peer.
func DefaultResourceManagerConfig ¶ added in v0.29.0
func DefaultResourceManagerConfig() *ResourceManagerConfig
type UnicastConfig ¶ added in v0.30.0
type UnicastConfig struct { // StreamRetryInterval is the initial delay between failing to establish a connection with another node and retrying. This // delay increases exponentially (exponential backoff) with the number of subsequent failures to establish a connection. StreamRetryInterval time.Duration // RateLimiterDistributor distributor that distributes notifications whenever a peer is rate limited to all consumers. RateLimiterDistributor p2p.UnicastRateLimiterDistributor }
UnicastConfig configuration parameters for the unicast manager.