Documentation ¶
Index ¶
- type Builder
- func (g *Builder) Build(ctx irrecoverable.SignalerContext) (p2p.PubSubAdapter, error)
- func (g *Builder) EnableGossipSubScoringWithOverride(override *p2p.PeerScoringConfigOverride)
- func (g *Builder) OverrideDefaultRpcInspectorSuiteFactory(factory p2p.GossipSubRpcInspectorSuiteFactoryFunc)
- func (g *Builder) SetGossipSubConfigFunc(gossipSubConfigFunc p2p.GossipSubAdapterConfigFunc)
- func (g *Builder) SetGossipSubFactory(gossipSubFactory p2p.GossipSubFactoryFunc)
- func (g *Builder) SetHost(h host.Host)
- func (g *Builder) SetRoutingSystem(routingSystem routing.Routing)
- func (g *Builder) SetSubscriptionFilter(subscriptionFilter pubsub.SubscriptionFilter)
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 ¶
func (g *Builder) Build(ctx irrecoverable.SignalerContext) (p2p.PubSubAdapter, error)
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 ¶
SetHost sets the host of the builder. If the host has already been set, a fatal error is logged.
func (*Builder) SetRoutingSystem ¶
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.