diff --git a/go.mod b/go.mod index a27fc5a958157875922046c27a0fa384190e7d30..7822f61265ca8d663ca5df393c8e94a2e182c5d0 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 + github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -31,7 +31,7 @@ require ( golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect - golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d // indirect + golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index dce6a55c34f4aa7b5fbe91c8ec2a134afa683552..ec6b36f293785832c8b732a0241f5d33cfad6715 100644 --- a/go.sum +++ b/go.sum @@ -95,6 +95,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 h1:/RAxj+VEPTykp9cWRKTtydkfuBDaFemI7/bdNYCD7Nw= github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 h1:al3bYvSaJnFyupe7bqgXYeBZ7W0fTNWrFd9WLLNlC6I= +github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= @@ -322,6 +324,8 @@ golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 h1:I7bfRTrfnb7yQSesz6OhwGVh2imeNUcbbS8YtFYC8Ck= +golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 526b92955cd1149624fd2110cfd268b38caaa754..f664c78aa6423f110aa338b7f2c2cffd7edb4178 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -103,24 +103,29 @@ func start() { } // add a service for the gossip - local.INSTANCE.UpdateService(service.GossipKey, &networkAddress{"tcp", gossipAddr}) - log.Debug("Local Services:", local.INSTANCE.Services().CreateRecord().String()) + if parameter.NodeConfig.GetBool(CFG_SELECTION) { + local.INSTANCE.UpdateService(service.GossipKey, "tcp", gossipAddr) + } Discovery = discover.New(local.INSTANCE, discover.Config{ Log: logger.Named("disc"), MasterPeers: masterPeers, }) - //if parameter.NodeConfig.GetBool(CFG_SELECTION) { - Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ - Log: logger.Named("sel"), - Param: &selection.Parameters{ - SaltLifetime: selection.DefaultSaltLifetime, - // RequiredService: []string{"gossip"}, - }, - }) + handlers := append([]server.Handler{}, Discovery) + + if parameter.NodeConfig.GetBool(CFG_SELECTION) { + Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ + Log: logger.Named("sel"), + Param: &selection.Parameters{ + SaltLifetime: selection.DefaultSaltLifetime, + // RequiredService: []string{"gossip"}, + }, + }) + handlers = append(handlers, Selection) + } // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), Discovery, Selection) + srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection @@ -176,18 +181,3 @@ func printReport(log *zap.SugaredLogger) { log.Info("Chosen:", len(outgoing)) log.Info("Accepted:", len(incoming)) } - -type networkAddress struct { - network string - address string -} - -// Network returns the service's network name. -func (a *networkAddress) Network() string { - return a.network -} - -// String returns the service's address in string form. -func (a *networkAddress) String() string { - return a.address -}