From ef5ab377679b696ea52b0e3b3c8e6e01fa821f01 Mon Sep 17 00:00:00 2001
From: Wolfgang Welz <welzwo@gmail.com>
Date: Fri, 10 Jan 2020 15:48:56 +0100
Subject: [PATCH] Fix: Allow starting a node with gossip disabled (#97)

* fix: remove selection flag and use gossip plugin

* Upgrade hive.go
---
 config.json                        | 3 +--
 go.mod                             | 2 +-
 go.sum                             | 4 ++--
 plugins/autopeering/autopeering.go | 5 ++++-
 plugins/autopeering/parameters.go  | 2 --
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config.json b/config.json
index 8550f628..ce6d80ba 100644
--- a/config.json
+++ b/config.json
@@ -8,8 +8,7 @@
     "entrynodes":[
       "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"
     ],
-    "port":14626,
-    "selection":true
+    "port":14626
   },
   "database":{
     "directory":"mainnetdb"
diff --git a/go.mod b/go.mod
index ffdc7762..90a5f495 100644
--- a/go.mod
+++ b/go.mod
@@ -11,7 +11,7 @@ require (
 	github.com/go-zeromq/zmq4 v0.7.0
 	github.com/golang/protobuf v1.3.2
 	github.com/gorilla/websocket v1.4.1
-	github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15
+	github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e
 	github.com/iotaledger/iota.go v1.0.0-beta.13
 	github.com/labstack/echo v3.3.10+incompatible
 	github.com/labstack/gommon v0.3.0 // indirect
diff --git a/go.sum b/go.sum
index 1a4c5f51..94b4893c 100644
--- a/go.sum
+++ b/go.sum
@@ -83,8 +83,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
 github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
-github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 h1:3QiXbekFTcuJJFnZUGZ9roLLykCD78Yz2aPZYh1QYLA=
-github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ=
+github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e h1:bowQHvFQoUWPgxlF9cQRWDzREswR09HpihMiNX1q+AU=
+github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ=
 github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
 github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc=
 github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go
index 4d70e09e..9f019a64 100644
--- a/plugins/autopeering/autopeering.go
+++ b/plugins/autopeering/autopeering.go
@@ -14,7 +14,9 @@ import (
 	"github.com/iotaledger/goshimmer/packages/autopeering/transport"
 	"github.com/iotaledger/goshimmer/packages/parameter"
 	"github.com/iotaledger/goshimmer/plugins/autopeering/local"
+	"github.com/iotaledger/goshimmer/plugins/gossip"
 	"github.com/iotaledger/hive.go/logger"
+	"github.com/iotaledger/hive.go/node"
 	"github.com/pkg/errors"
 )
 
@@ -39,7 +41,8 @@ func configureAP() {
 		MasterPeers: masterPeers,
 	})
 
-	if parameter.NodeConfig.GetBool(CFG_SELECTION) {
+	// enable peer selection only when gossip is enabled
+	if !node.IsSkipped(gossip.PLUGIN) {
 		Selection = selection.New(local.GetInstance(), Discovery, selection.Config{
 			Log: log.Named("sel"),
 			Param: &selection.Parameters{
diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go
index 0c245427..138b8d56 100644
--- a/plugins/autopeering/parameters.go
+++ b/plugins/autopeering/parameters.go
@@ -6,10 +6,8 @@ import (
 
 const (
 	CFG_ENTRY_NODES = "autopeering.entryNodes"
-	CFG_SELECTION   = "autopeering.selection"
 )
 
 func init() {
 	flag.StringSlice(CFG_ENTRY_NODES, []string{"V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"}, "list of trusted entry nodes for auto peering")
-	flag.Bool(CFG_SELECTION, true, "enable peer selection")
 }
-- 
GitLab