提交 afa1f154 作者: Jeromy Johnson 提交者: GitHub

Merge pull request #3381 from ipfs/feat/disable-bw-stats

add config option to disable bandwidth metrics
...@@ -93,6 +93,11 @@ Example: ...@@ -93,6 +93,11 @@ Example:
return return
} }
if nd.Reporter == nil {
res.SetError(fmt.Errorf("bandwidth reporter disabled in config"), cmds.ErrNormal)
return
}
pstr, pfound, err := req.Option("peer").String() pstr, pfound, err := req.Option("peer").String()
if err != nil { if err != nil {
res.SetError(err, cmds.ErrNormal) res.SetError(err, cmds.ErrNormal)
......
...@@ -143,9 +143,6 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin ...@@ -143,9 +143,6 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
return err return err
} }
// Set reporter
n.Reporter = metrics.NewBandwidthCounter()
// get undialable addrs from config // get undialable addrs from config
cfg, err := n.Repo.Config() cfg, err := n.Repo.Config()
if err != nil { if err != nil {
...@@ -160,6 +157,11 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin ...@@ -160,6 +157,11 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
addrfilter = append(addrfilter, f) addrfilter = append(addrfilter, f)
} }
if !cfg.Swarm.DisableBandwidthMetrics {
// Set reporter
n.Reporter = metrics.NewBandwidthCounter()
}
peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, addrfilter) peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter, addrfilter)
if err != nil { if err != nil {
return err return err
......
...@@ -213,5 +213,10 @@ Options for configuring the swarm. ...@@ -213,5 +213,10 @@ Options for configuring the swarm.
An array of address filters (multiaddr netmasks) to filter dials to. An array of address filters (multiaddr netmasks) to filter dials to.
See https://github.com/ipfs/go-ipfs/issues/1226#issuecomment-120494604 for more information. See https://github.com/ipfs/go-ipfs/issues/1226#issuecomment-120494604 for more information.
- `DisableBandwidthMetrics`
A boolean value that when set to true, will cause ipfs to not keep track of
bandwidth metrics. Disabling bandwidth metrics can lead to a slight performance
improvement, as well as a reduction in memory usage.
## `Tour` ## `Tour`
Unused. Unused.
package config package config
type SwarmConfig struct { type SwarmConfig struct {
AddrFilters []string AddrFilters []string
DisableBandwidthMetrics bool
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论