p2pbuilder

package
v0.31.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

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 DefaultNodeBuilder added in v0.29.0

func DefaultNodeBuilder(log zerolog.Logger,
	address string,
	flowKey fcrypto.PrivateKey,
	sporkId flow.Identifier,
	idProvider module.IdentityProvider,
	metricsCfg *p2pconfig.MetricsConfig,
	resolver madns.BasicResolver,
	role string,
	connGaterCfg *p2pconfig.ConnectionGaterConfig,
	peerManagerCfg *p2pconfig.PeerManagerConfig,
	gossipCfg *GossipSubConfig,
	rpcInspectorSuite p2p.GossipSubInspectorSuite,
	rCfg *ResourceManagerConfig,
	uniCfg *p2pconfig.UnicastConfig,
	routingSystemActivation DhtSystemActivation) (p2p.NodeBuilder, error)

DefaultNodeBuilder returns a node builder.

Types

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 DhtSystemActivation added in v0.31.24

type DhtSystemActivation bool
const (
	DhtSystemEnabled  DhtSystemActivation = true
	DhtSystemDisabled DhtSystemActivation = false
)

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
	// RpcInspector configuration for all gossipsub RPC control message inspectors.
	RpcInspector *inspector.GossipSubRPCInspectorsConfig
}

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 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 (*LibP2PNodeBuilder) SetGossipSubRpcInspectorSuite added in v0.31.0

func (builder *LibP2PNodeBuilder) SetGossipSubRpcInspectorSuite(inspectorSuite p2p.GossipSubInspectorSuite) 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 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL