mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +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
|
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
|
|||||||
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
|
|||||||
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.
|
|||||||
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.
|
||||||
|
@ -2,4 +2,5 @@ package config
|
|||||||
|
|
||||||
type SwarmConfig struct {
|
type SwarmConfig struct {
|
||||||
AddrFilters []string
|
AddrFilters []string
|
||||||
|
DisableBandwidthMetrics bool
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user