From 2a258a2c3f1c87bf2a3dbb991bef9c6dc85074c3 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 13 Mar 2018 10:57:21 +0400 Subject: [PATCH] revert removing private peers from persistent --- config/config.go | 1 + config/toml.go | 1 + docs/specification/configuration.rst | 1 + node/node.go | 31 +--------------------------- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/config/config.go b/config/config.go index 64da6373..6b3f87b5 100644 --- a/config/config.go +++ b/config/config.go @@ -251,6 +251,7 @@ type P2PConfig struct { Seeds string `mapstructure:"seeds"` // Comma separated list of nodes to keep persistent connections to + // Do not add private peers to this list if you don't want them advertised PersistentPeers string `mapstructure:"persistent_peers"` // Skip UPNP port forwarding diff --git a/config/toml.go b/config/toml.go index e40fe8fd..305e98d1 100644 --- a/config/toml.go +++ b/config/toml.go @@ -127,6 +127,7 @@ laddr = "{{ .P2P.ListenAddress }}" seeds = "" # Comma separated list of nodes to keep persistent connections to +# Do not add private peers to this list if you don't want them advertised persistent_peers = "" # Path to address book diff --git a/docs/specification/configuration.rst b/docs/specification/configuration.rst index 31490507..2a9ad794 100644 --- a/docs/specification/configuration.rst +++ b/docs/specification/configuration.rst @@ -89,6 +89,7 @@ like the file below, however, double check by inspecting the seeds = "" # Comma separated list of nodes to keep persistent connections to + # Do not add private peers to this list if you don't want them advertised persistent_peers = "" # Path to address book diff --git a/node/node.go b/node/node.go index 94616b0c..9d60f3d0 100644 --- a/node/node.go +++ b/node/node.go @@ -422,39 +422,10 @@ func (n *Node) OnStart() error { // Always connect to persistent peers if n.config.P2P.PersistentPeers != "" { - // are any of the persistent peers private? - persistentPeers := []string{} - persistentAndPrivatePeers := []string{} - var privatePeerIDs []string - if n.config.P2P.PrivatePeerIDs != "" { - privatePeerIDs = strings.Split(n.config.P2P.PrivatePeerIDs, ",") - } - PP_LOOP: - for _, peer := range strings.Split(n.config.P2P.PersistentPeers, ",") { - spl := strings.Split(peer, "@") - if len(spl) == 2 { - for _, ppID := range privatePeerIDs { - if spl[0] == ppID { - persistentAndPrivatePeers = append(persistentAndPrivatePeers, peer) - continue PP_LOOP - } - } - } - persistentPeers = append(persistentPeers, peer) - } - - err = n.sw.DialPeersAsync(n.addrBook, persistentPeers, true) + err = n.sw.DialPeersAsync(n.addrBook, strings.Split(n.config.P2P.PersistentPeers, ","), true) if err != nil { return err } - - // if any of the persistent peers are private, do not add them to addrbook - if len(persistentAndPrivatePeers) > 0 { - err = n.sw.DialPeersAsync(nil, persistentAndPrivatePeers, true) - if err != nil { - return err - } - } } // start tx indexer