mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
add config option to disable bandwidth metrics
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
This commit is contained in:
@ -93,6 +93,11 @@ Example:
|
||||
return
|
||||
}
|
||||
|
||||
if nd.Reporter == nil {
|
||||
res.SetError(fmt.Errorf("bandwidth reporter disabled in config"), cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
pstr, pfound, err := req.Option("peer").String()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
|
@ -143,9 +143,6 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
|
||||
return err
|
||||
}
|
||||
|
||||
// Set reporter
|
||||
n.Reporter = metrics.NewBandwidthCounter()
|
||||
|
||||
// get undialable addrs from config
|
||||
cfg, err := n.Repo.Config()
|
||||
if err != nil {
|
||||
@ -160,6 +157,11 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -213,5 +213,10 @@ Options for configuring the swarm.
|
||||
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.
|
||||
|
||||
- `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`
|
||||
Unused.
|
||||
|
@ -1,5 +1,6 @@
|
||||
package config
|
||||
|
||||
type SwarmConfig struct {
|
||||
AddrFilters []string
|
||||
AddrFilters []string
|
||||
DisableBandwidthMetrics bool
|
||||
}
|
||||
|
Reference in New Issue
Block a user