p2pbuilder

package
v0.28.10 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 DefaultMessageIDFunction

func DefaultMessageIDFunction(msg *pb.Message) string

DefaultMessageIDFunction returns a default message ID function based on the message's data

func DefaultPubsubOptions

func DefaultPubsubOptions(maxPubSubMsgSize int) []pubsub.Option

Types

type LibP2PFactoryFunc

type LibP2PFactoryFunc func() (*p2pnode.Node, 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,
	connectionPruning bool,
	updateInterval time.Duration,
) 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,
	addr string,
	networkKey fcrypto.PrivateKey,
	sporkID flow.Identifier,
) *LibP2PNodeBuilder

func (*LibP2PNodeBuilder) Build

func (builder *LibP2PNodeBuilder) Build() (*p2pnode.Node, 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

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) SetPeerManagerOptions

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

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(module.IdentityProvider, ...scoring.PeerScoreParamsOption) NodeBuilder
	Build() (*p2pnode.Node, error)
}

Jump to

Keyboard shortcuts

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