From d59ca83d48b65c977e19fb16b23c27801dcf7d36 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Oct 2018 07:44:25 -0700 Subject: [PATCH] switch to DisablePing instead of PingCustom --- config/config.go | 5 ++--- defaults.go | 9 --------- options.go | 3 +-- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/config/config.go b/config/config.go index 520cfb9..dd3d399 100644 --- a/config/config.go +++ b/config/config.go @@ -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. @@ -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() diff --git a/defaults.go b/defaults.go index f44f84d..679fd7a 100644 --- a/defaults.go +++ b/defaults.go @@ -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 @@ -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 diff --git a/options.go b/options.go index 9c69744..4ab4f39 100644 --- a/options.go +++ b/options.go @@ -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 } } -- GitLab