p2pbuilder

package
v0.29.16-height-coordi... Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: AGPL-3.0 Imports: 37 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 *p2pnode.ProtocolPeerCache,
	uniMgr *unicast.Manager,
	peerManager *connection.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

Types

type CreateNodeFunc added in v0.29.0

type CreateNodeFunc func(logger zerolog.Logger,
	host host.Host,
	pCache *p2pnode.ProtocolPeerCache,
	uniMgr *unicast.Manager,
	peerManager *connection.PeerManager) p2p.LibP2PNode

type GossipSubAdapterConfigFunc added in v0.29.0

type GossipSubAdapterConfigFunc func(*p2p.BasePubSubAdapterConfig) p2p.PubSubAdapterConfig

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.

func DefaultLibP2PNodeFactory

func DefaultLibP2PNodeFactory(log zerolog.Logger,
	address string,
	flowKey fcrypto.PrivateKey,
	sporkId flow.Identifier,
	idProvider module.IdentityProvider,
	metrics module.NetworkMetrics,
	resolver madns.BasicResolver,
	peerScoringEnabled bool,
	role string,
	onInterceptPeerDialFilters, onInterceptSecuredFilters []p2p.PeerFilter,
	connectionPruning bool,
	updateInterval time.Duration,
	rCfg *ResourceManagerConfig) LibP2PFactoryFunc

DefaultLibP2PNodeFactory returns a LibP2PFactoryFunc which generates the libp2p host initialized with the default options for the host, the pubsub and the ping service.

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, ops ...scoring.PeerScoreParamsOption) NodeBuilder

EnableGossipSubPeerScoring sets builder.gossipSubPeerScoring to true.

func (*LibP2PNodeBuilder) SetBasicResolver

func (builder *LibP2PNodeBuilder) SetBasicResolver(br madns.BasicResolver) NodeBuilder

SetBasicResolver sets the DNS resolver for the node.

func (*LibP2PNodeBuilder) SetConnectionGater

func (builder *LibP2PNodeBuilder) SetConnectionGater(gater connmgr.ConnectionGater) NodeBuilder

SetConnectionGater sets the connection gater for the node.

func (*LibP2PNodeBuilder) SetConnectionManager

func (builder *LibP2PNodeBuilder) SetConnectionManager(manager connmgr.ConnManager) NodeBuilder

SetConnectionManager sets the connection manager for the node.

func (*LibP2PNodeBuilder) SetCreateNode added in v0.29.0

func (builder *LibP2PNodeBuilder) SetCreateNode(f CreateNodeFunc) NodeBuilder

func (*LibP2PNodeBuilder) SetGossipSubFactory added in v0.29.0

func (*LibP2PNodeBuilder) SetPeerManagerOptions

func (builder *LibP2PNodeBuilder) SetPeerManagerOptions(connectionPruning bool, updateInterval time.Duration) NodeBuilder

SetPeerManagerOptions sets the peer manager options.

func (*LibP2PNodeBuilder) SetResourceManager

func (builder *LibP2PNodeBuilder) SetResourceManager(manager network.ResourceManager) 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)) NodeBuilder

SetRoutingSystem sets the routing factory function.

func (*LibP2PNodeBuilder) SetSubscriptionFilter

func (builder *LibP2PNodeBuilder) SetSubscriptionFilter(filter pubsub.SubscriptionFilter) NodeBuilder

SetSubscriptionFilter sets the pubsub subscription filter for the node.

type NodeBuilder

type NodeBuilder interface {
	SetBasicResolver(madns.BasicResolver) NodeBuilder
	SetSubscriptionFilter(pubsub.SubscriptionFilter) NodeBuilder
	SetResourceManager(network.ResourceManager) NodeBuilder
	SetConnectionManager(connmgr.ConnManager) NodeBuilder
	SetConnectionGater(connmgr.ConnectionGater) NodeBuilder
	SetRoutingSystem(func(context.Context, host.Host) (routing.Routing, error)) NodeBuilder
	SetPeerManagerOptions(connectionPruning bool, updateInterval time.Duration) NodeBuilder
	EnableGossipSubPeerScoring(provider module.IdentityProvider, ops ...scoring.PeerScoreParamsOption) NodeBuilder
	SetCreateNode(CreateNodeFunc) NodeBuilder
	SetGossipSubFactory(GossipSubFactoryFunc, GossipSubAdapterConfigFunc) NodeBuilder
	Build() (p2p.LibP2PNode, error)
}

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,
	onInterceptPeerDialFilters, onInterceptSecuredFilters []p2p.PeerFilter,
	peerScoringEnabled bool,
	connectionPruning bool,
	updateInterval time.Duration,
	rCfg *ResourceManagerConfig) NodeBuilder

DefaultNodeBuilder returns a node builder.

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]
}

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

Jump to

Keyboard shortcuts

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