@cryptotaxi247 / kubo / commits / 43d668331

add config option to disable bandwidth metrics

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Nov 11, 2016 at 10:31 UTC 43d668331c19168bc337680e662b744ff1d9e6a8
4 files changed +17 -4
core/commands/stat.go
+5
@@ -93,6 +93,11 @@ Example:
93 return
94 }
95
96 + if nd.Reporter == nil {
97 + res.SetError(fmt.Errorf("bandwidth reporter disabled in config"), cmds.ErrNormal)
98 + return
99 + }
100 +
101 pstr, pfound, err := req.Option("peer").String()
102 if err != nil {
103 res.SetError(err, cmds.ErrNormal)
core/core.go
+5 -3
@@ -143,9 +143,6 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
143 return err
144 }
145
146 - // Set reporter
147 - n.Reporter = metrics.NewBandwidthCounter()
148 -
146 // get undialable addrs from config
147 cfg, err := n.Repo.Config()
148 if err != nil {
@@ -160,6 +157,11 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
157 addrfilter = append(addrfilter, f)
158 }
159
160 + if !cfg.Swarm.DisableBandwidthMetrics {
161 + // Set reporter
162 + n.Reporter = metrics.NewBandwidthCounter()
163 + }
164 +
165 peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, addrfilter)
166 if err != nil {
167 return err
docs/config.md
+5
@@ -213,5 +213,10 @@ Options for configuring the swarm.
213 An array of address filters (multiaddr netmasks) to filter dials to.
214 See https://github.com/ipfs/go-ipfs/issues/1226#issuecomment-120494604 for more information.
215
216 +- `DisableBandwidthMetrics`
217 +A boolean value that when set to true, will cause ipfs to not keep track of
218 +bandwidth metrics. Disabling bandwidth metrics can lead to a slight performance
219 +improvement, as well as a reduction in memory usage.
220 +
221 ## `Tour`
222 Unused.
repo/config/swarm.go
+2 -1
@@ -1,5 +1,6 @@
1 package config
2
3 type SwarmConfig struct {
4 - AddrFilters []string
4 + AddrFilters []string
5 + DisableBandwidthMetrics bool
6 }