Skip to content

Commit

Permalink
Merge pull request #462 from libp2p/fix/no-custom-field
Browse files Browse the repository at this point in the history
switch to DisablePing instead of PingCustom
  • Loading branch information
Stebalien committed Oct 24, 2018
2 parents 30e4db2 + d59ca83 commit 6a74328
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
5 changes: 2 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ type Config struct {
Peerstore pstore.Peerstore
Reporter metrics.Reporter

PingCustom bool
Ping bool
DisablePing bool
}

// NewNode constructs a new libp2p Host from the Config.
Expand Down Expand Up @@ -105,7 +104,7 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
ConnManager: cfg.ConnManager,
AddrsFactory: cfg.AddrsFactory,
NATManager: cfg.NATManager,
EnablePing: cfg.Ping,
EnablePing: !cfg.DisablePing,
})
if err != nil {
swrm.Close()
Expand Down
9 changes: 0 additions & 9 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ var DefaultEnableRelay = func(cfg *Config) error {
return cfg.Apply(EnableRelay())
}

// DefaultEnablePing enables the ping service by default
var DefaultEnablePing = func(cfg *Config) error {
return cfg.Apply(Ping(true))
}

// Complete list of default options and when to fallback on them.
//
// Please *DON'T* specify default options any other way. Putting this all here
Expand Down Expand Up @@ -116,10 +111,6 @@ var defaults = []struct {
fallback: func(cfg *Config) bool { return !cfg.RelayCustom },
opt: DefaultEnableRelay,
},
{
fallback: func(cfg *Config) bool { return !cfg.PingCustom },
opt: DefaultEnablePing,
},
}

// Defaults configures libp2p to use the default options. Can be combined with
Expand Down
3 changes: 1 addition & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ func NATManager(nm config.NATManagerC) Option {
// Ping will configure libp2p to support the ping service; enable by default.
func Ping(enable bool) Option {
return func(cfg *Config) error {
cfg.PingCustom = true
cfg.Ping = enable
cfg.DisablePing = !enable
return nil
}
}
Expand Down

0 comments on commit 6a74328

Please sign in to comment.