@@ -12,6 +12,7 @@ import (
1212 "github.com/onflow/flow-go/module/mempool/queue"
1313 "github.com/onflow/flow-go/module/metrics"
1414 "github.com/onflow/flow-go/network/p2p"
15+ "github.com/onflow/flow-go/network/p2p/distributor"
1516 "github.com/onflow/flow-go/network/p2p/inspector"
1617 "github.com/onflow/flow-go/network/p2p/inspector/validation"
1718 "github.com/onflow/flow-go/network/p2p/p2pnode"
@@ -49,6 +50,30 @@ type GossipSubRPCInspectorsConfig struct {
4950 MetricsInspectorConfigs * GossipSubRPCMetricsInspectorConfigs
5051}
5152
53+ func DefaultGossipSubRPCInspectorsConfig () * GossipSubRPCInspectorsConfig {
54+ return & GossipSubRPCInspectorsConfig {
55+ GossipSubRPCInspectorNotificationCacheSize : distributor .DefaultGossipSubInspectorNotificationQueueCacheSize ,
56+ ValidationInspectorConfigs : & GossipSubRPCValidationInspectorConfigs {
57+ NumberOfWorkers : validation .DefaultNumberOfWorkers ,
58+ CacheSize : validation .DefaultControlMsgValidationInspectorQueueCacheSize ,
59+ GraftLimits : map [string ]int {
60+ validation .DiscardThresholdMapKey : validation .DefaultGraftDiscardThreshold ,
61+ validation .SafetyThresholdMapKey : validation .DefaultGraftSafetyThreshold ,
62+ validation .RateLimitMapKey : validation .DefaultGraftRateLimit ,
63+ },
64+ PruneLimits : map [string ]int {
65+ validation .DiscardThresholdMapKey : validation .DefaultPruneDiscardThreshold ,
66+ validation .SafetyThresholdMapKey : validation .DefaultPruneSafetyThreshold ,
67+ validation .RateLimitMapKey : validation .DefaultPruneRateLimit ,
68+ },
69+ },
70+ MetricsInspectorConfigs : & GossipSubRPCMetricsInspectorConfigs {
71+ NumberOfWorkers : inspector .DefaultControlMsgMetricsInspectorNumberOfWorkers ,
72+ CacheSize : inspector .DefaultControlMsgMetricsInspectorQueueCacheSize ,
73+ },
74+ }
75+ }
76+
5277// GossipSubInspectorBuilder builder that constructs all rpc inspectors used by gossip sub. The following
5378// rpc inspectors are created with this builder.
5479// - validation inspector: performs validation on all control messages.
@@ -65,22 +90,27 @@ type GossipSubInspectorBuilder struct {
6590}
6691
6792// NewGossipSubInspectorBuilder returns new *GossipSubInspectorBuilder.
68- func NewGossipSubInspectorBuilder (logger zerolog.Logger , sporkID flow.Identifier , inspectorsConfig * GossipSubRPCInspectorsConfig , distributor p2p.GossipSubInspectorNotificationDistributor , netMetrics module. NetworkMetrics , metricsRegistry prometheus. Registerer ) * GossipSubInspectorBuilder {
93+ func NewGossipSubInspectorBuilder (logger zerolog.Logger , sporkID flow.Identifier , inspectorsConfig * GossipSubRPCInspectorsConfig , distributor p2p.GossipSubInspectorNotificationDistributor ) * GossipSubInspectorBuilder {
6994 return & GossipSubInspectorBuilder {
7095 logger : logger ,
7196 sporkID : sporkID ,
7297 inspectorsConfig : inspectorsConfig ,
7398 distributor : distributor ,
74- netMetrics : netMetrics ,
75- metricsRegistry : metricsRegistry ,
76- metricsEnabled : true ,
77- publicNetwork : true ,
99+ metricsEnabled : p2p .MetricsDisabled ,
100+ publicNetwork : p2p .PublicNetworkEnabled ,
78101 }
79102}
80103
81104// SetMetricsEnabled disable and enable metrics collection for the inspectors underlying hero store cache.
82- func (b * GossipSubInspectorBuilder ) SetMetricsEnabled (enabled bool ) * GossipSubInspectorBuilder {
83- b .metricsEnabled = enabled
105+ func (b * GossipSubInspectorBuilder ) SetMetricsEnabled (metricsEnabled bool ) * GossipSubInspectorBuilder {
106+ b .metricsEnabled = metricsEnabled
107+ return b
108+ }
109+
110+ // SetMetrics sets the network metrics and registry.
111+ func (b * GossipSubInspectorBuilder ) SetMetrics (netMetrics module.NetworkMetrics , metricsRegistry prometheus.Registerer ) * GossipSubInspectorBuilder {
112+ b .netMetrics = netMetrics
113+ b .metricsRegistry = metricsRegistry
84114 return b
85115}
86116
0 commit comments