gossipsubbuilder

package
v0.33.21-fix-get-highe... Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

The Builder struct is used to configure and create a new GossipSub pubsub system.

func NewGossipSubBuilder

func NewGossipSubBuilder(logger zerolog.Logger,
	metricsCfg *p2pbuilderconfig.MetricsConfig,
	gossipSubCfg *p2pconfig.GossipSubParameters,
	networkType network.NetworkingType,
	sporkId flow.Identifier,
	idProvider module.IdentityProvider) *Builder

NewGossipSubBuilder returns a new gossipsub builder. Args: - logger: the logger of the node. - metricsCfg: the metrics config of the node. - networkType: the network type of the node. - sporkId: the spork id of the node. - idProvider: the identity provider of the node. - rpcInspectorConfig: the rpc inspector config of the node. Returns: - a new gossipsub builder. Note: the builder is not thread-safe. It should only be used in the main thread.

func (*Builder) Build

Build creates a new GossipSub pubsub system. It returns the newly created GossipSub pubsub system and any errors encountered during its creation. Arguments: - ctx: the irrecoverable context of the node.

Returns: - p2p.PubSubAdapter: a GossipSub pubsub system for the libp2p node. - p2p.PeerScoreTracer: a peer score tracer for the GossipSub pubsub system (if enabled, otherwise nil). - error: if an error occurs during the creation of the GossipSub pubsub system, it is returned. Otherwise, nil is returned. Note that on happy path, the returned error is nil. Any error returned is unexpected and should be handled as irrecoverable.

func (*Builder) EnableGossipSubScoringWithOverride

func (g *Builder) EnableGossipSubScoringWithOverride(override *p2p.PeerScoringConfigOverride)

EnableGossipSubScoringWithOverride enables peer scoring for the GossipSub pubsub system with the given override. 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. Production Tip: use PeerScoringConfigNoOverride as the argument to this function to enable peer scoring without any override. Args: - PeerScoringConfigOverride: override for the peer scoring config- Recommended to use PeerScoringConfigNoOverride for production. Returns: none

func (*Builder) OverrideDefaultRpcInspectorSuiteFactory

func (g *Builder) OverrideDefaultRpcInspectorSuiteFactory(factory p2p.GossipSubRpcInspectorSuiteFactoryFunc)

OverrideDefaultRpcInspectorSuiteFactory overrides the default rpc inspector suite factory. Note: this function should only be used for testing purposes. Never override the default rpc inspector suite factory unless you know what you are doing.

func (*Builder) SetGossipSubConfigFunc

func (g *Builder) SetGossipSubConfigFunc(gossipSubConfigFunc p2p.GossipSubAdapterConfigFunc)

SetGossipSubConfigFunc sets the gossipsub config function of the builder. We expect the node to initialize with a default gossipsub config. Hence, this function overrides the default config.

func (*Builder) SetGossipSubFactory

func (g *Builder) SetGossipSubFactory(gossipSubFactory p2p.GossipSubFactoryFunc)

SetGossipSubFactory sets the gossipsub factory of the builder. We expect the node to initialize with a default gossipsub factory. Hence, this function overrides the default config.

func (*Builder) SetHost

func (g *Builder) SetHost(h host.Host)

SetHost sets the host of the builder. If the host has already been set, a fatal error is logged.

func (*Builder) SetRoutingSystem

func (g *Builder) SetRoutingSystem(routingSystem routing.Routing)

SetRoutingSystem sets the routing system of the builder. If the routing system has already been set, a fatal error is logged.

func (*Builder) SetSubscriptionFilter

func (g *Builder) SetSubscriptionFilter(subscriptionFilter pubsub.SubscriptionFilter)

SetSubscriptionFilter sets the subscription filter of the builder. If the subscription filter has already been set, a fatal error is logged.

Jump to

Keyboard shortcuts

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