p2pbuilder

package
v0.33.30 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: AGPL-3.0 Imports: 46 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyResourceLimitOverride

func ApplyResourceLimitOverride(logger zerolog.Logger,
	resourceScope p2pconfig.ResourceScope,
	original rcmgr.ResourceLimits,
	override p2pconfig.ResourceManagerOverrideLimit) rcmgr.ResourceLimits

ApplyResourceLimitOverride applies the override limit to the original limit. For any attribute that is set in the override limit, the original limit will be overridden, otherwise the original limit will be used. Args:

	logger: logger to log the override limit.
	resourceScope: the scope of the resource, e.g., system, transient, protocol, peer, peer-protocol.
	original: the original limit.
 override: the override limit.

Returns:

the overridden limit.

func BuildLibp2pResourceManagerLimits

func BuildLibp2pResourceManagerLimits(logger zerolog.Logger, config *p2pconfig.ResourceManagerConfig) (*rcmgr.ConcreteLimitConfig, error)

BuildLibp2pResourceManagerLimits builds the resource manager limits for the libp2p node. Args:

logger: logger to log the resource manager limits.
config: the resource manager configuration.

Returns:

  • the resource manager limits.
  • any error encountered, all returned errors are irrecoverable (we cannot continue without the resource manager limits).

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

func DefaultNodeBuilder(
	logger zerolog.Logger,
	address string,
	networkingType flownet.NetworkingType,
	flowKey fcrypto.PrivateKey,
	sporkId flow.Identifier,
	idProvider module.IdentityProvider,
	metricsCfg *p2pbuilderconfig.MetricsConfig,
	resolver madns.BasicResolver,
	role string,
	connGaterCfg *p2pbuilderconfig.ConnectionGaterConfig,
	peerManagerCfg *p2pbuilderconfig.PeerManagerConfig,
	gossipCfg *p2pconfig.GossipSubParameters,
	rCfg *p2pconfig.ResourceManagerConfig,
	uniCfg *p2pbuilderconfig.UnicastConfig,
	connMgrConfig *netconf.ConnectionManager,
	disallowListCacheCfg *p2p.DisallowListCacheConfig,
	dhtSystemActivation DhtSystemActivation,
) (p2p.NodeBuilder, error)

DefaultNodeBuilder returns a node builder.

Types

type DhtSystemActivation

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

type LibP2PNodeBuilder

type LibP2PNodeBuilder struct {
	// contains filtered or unexported fields
}

func NewNodeBuilder

func NewNodeBuilder(
	logger zerolog.Logger,
	gossipSubCfg *p2pconfig.GossipSubParameters,
	metricsConfig *p2pbuilderconfig.MetricsConfig,
	networkingType flownet.NetworkingType,
	address string,
	networkKey fcrypto.PrivateKey,
	sporkId flow.Identifier,
	idProvider module.IdentityProvider,
	rCfg *p2pconfig.ResourceManagerConfig,
	peerManagerConfig *p2pbuilderconfig.PeerManagerConfig,
	disallowListCacheCfg *p2p.DisallowListCacheConfig,
	unicastConfig *p2pbuilderconfig.UnicastConfig,
) *LibP2PNodeBuilder

func (*LibP2PNodeBuilder) Build

func (builder *LibP2PNodeBuilder) Build() (p2p.LibP2PNode, error)

Build creates a new libp2p node using the configured options.

func (*LibP2PNodeBuilder) OverrideDefaultRpcInspectorFactory added in v0.33.30

func (builder *LibP2PNodeBuilder) OverrideDefaultRpcInspectorFactory(factory p2p.GossipSubRpcInspectorFactoryFunc) p2p.NodeBuilder

OverrideDefaultRpcInspectorFactory overrides the default rpc inspector factory for the GossipSub protocol. The purpose of override is to allow the node to provide a custom rpc inspector factory for sake of testing or experimentation. Note: it is not recommended to override the default rpc inspector factory in production unless you know what you are doing. Args: - factory: custom rpc inspector factory Returns: - NodeBuilder: the node builder

func (*LibP2PNodeBuilder) OverrideGossipSubFactory added in v0.33.30

func (builder *LibP2PNodeBuilder) OverrideGossipSubFactory(gf p2p.GossipSubFactoryFunc, cf p2p.GossipSubAdapterConfigFunc) p2p.NodeBuilder

OverrideGossipSubFactory overrides the default gossipsub factory for the GossipSub protocol. The purpose of override is to allow the node to provide a custom gossipsub factory for sake of testing or experimentation. Note: it is not recommended to override the default gossipsub factory in production unless you know what you are doing. Args: - factory: custom gossipsub factory Returns: - NodeBuilder: the node builder

func (*LibP2PNodeBuilder) OverrideGossipSubScoringConfig

func (builder *LibP2PNodeBuilder) OverrideGossipSubScoringConfig(config *p2p.PeerScoringConfigOverride) p2p.NodeBuilder

OverrideGossipSubScoringConfig overrides the default peer scoring config for the GossipSub protocol. Note that it does not enable peer scoring. The peer scoring is enabled directly by setting the `peer-scoring-enabled` flag to true in `default-config.yaml`, or by setting the `gossipsub-peer-scoring-enabled` runtime flag to true. This function only overrides the default peer scoring config which takes effect only if the peer scoring is enabled (mostly for testing purposes). Any existing peer scoring config attribute that is set in the override will override the default peer scoring config. Anything that is left to nil or zero value in the override will be ignored and the default value will be used. Note: it is not recommended to override the default peer scoring config in production unless you know what you are doing. Args: - PeerScoringConfigOverride: override for the peer scoring config- Recommended to use PeerScoringConfigNoOverride for production. Returns: none

func (*LibP2PNodeBuilder) OverrideNodeConstructor

func (builder *LibP2PNodeBuilder) OverrideNodeConstructor(f p2p.NodeConstructor) p2p.NodeBuilder

OverrideNodeConstructor overrides the default node constructor, i.e., the function that creates a new libp2p node. The purpose of override is to allow the node to provide a custom node constructor for sake of testing or experimentation. It is NOT recommended to override the default node constructor in production unless you know what you are doing. Args: - NodeConstructor: custom node constructor Returns: none

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 p2p.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) 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) SetSubscriptionFilter

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

SetSubscriptionFilter sets the pubsub subscription filter for the node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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