diff --git a/pluginmgr/core/plugins.go b/pluginmgr/core/plugins.go index 401d430a1c4ed697bd54905d0a484924425742bc..e0e508578dba66cda616d24abbfb70b66f856e50 100644 --- a/pluginmgr/core/plugins.go +++ b/pluginmgr/core/plugins.go @@ -28,7 +28,7 @@ var PLUGINS = node.Plugins( database.PLUGIN, autopeering.Plugin, messagelayer.PLUGIN, - gossip.PLUGIN, + gossip.Plugin, gracefulshutdown.PLUGIN, metrics.PLUGIN, drng.PLUGIN, diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 64754dd30687f3d907d9fbb414a5a7de05c2da06..db01bc67d6f5dd7ad4d5ac2a9924bc23669e3bb5 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -75,7 +75,7 @@ func configureAP() { ) // enable peer selection only when gossip is enabled - if !node.IsSkipped(gossip.PLUGIN) { + if !node.IsSkipped(gossip.Plugin) { Selection = selection.New(local.GetInstance(), Discovery, selection.Logger(log.Named("sel")), selection.NeighborValidator(selection.ValidatorFunc(isValidNeighbor)), diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index add51aa795dc5daebeea5d833dfe6164a0e84963..3136d28177a64c8e82fef0c41cf469da6c0d3914 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -185,7 +185,7 @@ func neighborMetrics() []neighbormetric { stats := []neighbormetric{} // gossip plugin might be disabled - neighbors := gossip.GetAllNeighbors() + neighbors := gossip.Neighbors() if neighbors == nil { return stats } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index be42070803563bd6d164cd4bf443ec41bf45c856..ea81051648c4b951d591e69aa7b0a25008e72cfb 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -27,9 +27,9 @@ func configureGossip() { lPeer := local.GetInstance() // announce the gossip service - gossipPort := config.Node.GetInt(GOSSIP_PORT) + gossipPort := config.Node.GetInt(CfgGossipPort) if !netutil.IsValidPort(gossipPort) { - log.Fatalf("Invalid port number (%s): %d", GOSSIP_PORT, gossipPort) + log.Fatalf("Invalid port number (%s): %d", CfgGossipPort, gossipPort) } if err := lPeer.UpdateService(service.GossipKey, "tcp", gossipPort); err != nil { @@ -39,7 +39,7 @@ func configureGossip() { } func start(shutdownSignal <-chan struct{}) { - defer log.Info("Stopping " + name + " ... done") + defer log.Info("Stopping " + pluginName + " ... done") lPeer := local.GetInstance() @@ -65,24 +65,25 @@ func start(shutdownSignal <-chan struct{}) { mgr.Start(srv) defer mgr.Close() - log.Infof("%s started: Address=%s/%s", name, localAddr.String(), localAddr.Network()) + log.Infof("%s started: Address=%s/%s", pluginName, localAddr.String(), localAddr.Network()) <-shutdownSignal - log.Info("Stopping " + name + " ...") + log.Info("Stopping " + pluginName + " ...") } // loads the given message from the message layer or an error if not found. -func loadMessage(messageId message.Id) (bytes []byte, err error) { - log.Debugw("load message from db", "id", messageId.String()) - if !messagelayer.Tangle.Message(messageId).Consume(func(message *message.Message) { +func loadMessage(messageID message.Id) (bytes []byte, err error) { + log.Debugw("load message from db", "id", messageID.String()) + if !messagelayer.Tangle.Message(messageID).Consume(func(message *message.Message) { bytes = message.Bytes() }) { - err = fmt.Errorf("message not found: hash=%s", messageId) + err = fmt.Errorf("message not found: hash=%s", messageID) } return } -func GetAllNeighbors() []*gp.Neighbor { +// Neighbors returns the list of the neighbors. +func Neighbors() []*gp.Neighbor { if mgr == nil { return nil } diff --git a/plugins/gossip/parameters.go b/plugins/gossip/parameters.go index aa96e7cbd674429c80c2af2c923a975651950bdc..ade8e8a22e94808dd3c130be13c20fb509e107e4 100644 --- a/plugins/gossip/parameters.go +++ b/plugins/gossip/parameters.go @@ -5,9 +5,10 @@ import ( ) const ( - GOSSIP_PORT = "gossip.port" + // CfgGossipPort defines the config flag of the gossip port. + CfgGossipPort = "gossip.port" ) func init() { - flag.Int(GOSSIP_PORT, 14666, "tcp port for gossip connection") + flag.Int(CfgGossipPort, 14666, "tcp port for gossip connection") } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index ef7ebeceeddc3133b7eac78e4bfe0ff9c330daff..c2f3a56f696898752b40393da8c799ab04f4ce49 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -15,19 +15,20 @@ import ( "github.com/iotaledger/goshimmer/plugins/messagelayer" ) -const name = "Gossip" // name of the plugin +const pluginName = "Gossip" // name of the plugin -var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) +// Plugin defines the gossip plugin +var Plugin = node.NewPlugin(pluginName, node.Enabled, configure, run) func configure(*node.Plugin) { - log = logger.NewLogger(name) + log = logger.NewLogger(pluginName) configureGossip() configureEvents() } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start, shutdown.PriorityGossip); err != nil { + if err := daemon.BackgroundWorker(pluginName, start, shutdown.PriorityGossip); err != nil { log.Errorf("Failed to start as daemon: %s", err) } }