Skip to content
Snippets Groups Projects
Commit dc73720a authored by capossele's avatar capossele
Browse files

:rotating_light: Fixes linter warnings.

parent 35a0c58c
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ var PLUGINS = node.Plugins( ...@@ -28,7 +28,7 @@ var PLUGINS = node.Plugins(
database.PLUGIN, database.PLUGIN,
autopeering.Plugin, autopeering.Plugin,
messagelayer.PLUGIN, messagelayer.PLUGIN,
gossip.PLUGIN, gossip.Plugin,
gracefulshutdown.PLUGIN, gracefulshutdown.PLUGIN,
metrics.PLUGIN, metrics.PLUGIN,
drng.PLUGIN, drng.PLUGIN,
......
...@@ -75,7 +75,7 @@ func configureAP() { ...@@ -75,7 +75,7 @@ func configureAP() {
) )
// enable peer selection only when gossip is enabled // 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 = selection.New(local.GetInstance(), Discovery,
selection.Logger(log.Named("sel")), selection.Logger(log.Named("sel")),
selection.NeighborValidator(selection.ValidatorFunc(isValidNeighbor)), selection.NeighborValidator(selection.ValidatorFunc(isValidNeighbor)),
......
...@@ -185,7 +185,7 @@ func neighborMetrics() []neighbormetric { ...@@ -185,7 +185,7 @@ func neighborMetrics() []neighbormetric {
stats := []neighbormetric{} stats := []neighbormetric{}
// gossip plugin might be disabled // gossip plugin might be disabled
neighbors := gossip.GetAllNeighbors() neighbors := gossip.Neighbors()
if neighbors == nil { if neighbors == nil {
return stats return stats
} }
......
...@@ -27,9 +27,9 @@ func configureGossip() { ...@@ -27,9 +27,9 @@ func configureGossip() {
lPeer := local.GetInstance() lPeer := local.GetInstance()
// announce the gossip service // announce the gossip service
gossipPort := config.Node.GetInt(GOSSIP_PORT) gossipPort := config.Node.GetInt(CfgGossipPort)
if !netutil.IsValidPort(gossipPort) { 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 { if err := lPeer.UpdateService(service.GossipKey, "tcp", gossipPort); err != nil {
...@@ -39,7 +39,7 @@ func configureGossip() { ...@@ -39,7 +39,7 @@ func configureGossip() {
} }
func start(shutdownSignal <-chan struct{}) { func start(shutdownSignal <-chan struct{}) {
defer log.Info("Stopping " + name + " ... done") defer log.Info("Stopping " + pluginName + " ... done")
lPeer := local.GetInstance() lPeer := local.GetInstance()
...@@ -65,24 +65,25 @@ func start(shutdownSignal <-chan struct{}) { ...@@ -65,24 +65,25 @@ func start(shutdownSignal <-chan struct{}) {
mgr.Start(srv) mgr.Start(srv)
defer mgr.Close() 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 <-shutdownSignal
log.Info("Stopping " + name + " ...") log.Info("Stopping " + pluginName + " ...")
} }
// loads the given message from the message layer or an error if not found. // loads the given message from the message layer or an error if not found.
func loadMessage(messageId message.Id) (bytes []byte, err error) { func loadMessage(messageID message.Id) (bytes []byte, err error) {
log.Debugw("load message from db", "id", messageId.String()) log.Debugw("load message from db", "id", messageID.String())
if !messagelayer.Tangle.Message(messageId).Consume(func(message *message.Message) { if !messagelayer.Tangle.Message(messageID).Consume(func(message *message.Message) {
bytes = message.Bytes() bytes = message.Bytes()
}) { }) {
err = fmt.Errorf("message not found: hash=%s", messageId) err = fmt.Errorf("message not found: hash=%s", messageID)
} }
return return
} }
func GetAllNeighbors() []*gp.Neighbor { // Neighbors returns the list of the neighbors.
func Neighbors() []*gp.Neighbor {
if mgr == nil { if mgr == nil {
return nil return nil
} }
......
...@@ -5,9 +5,10 @@ import ( ...@@ -5,9 +5,10 @@ import (
) )
const ( const (
GOSSIP_PORT = "gossip.port" // CfgGossipPort defines the config flag of the gossip port.
CfgGossipPort = "gossip.port"
) )
func init() { func init() {
flag.Int(GOSSIP_PORT, 14666, "tcp port for gossip connection") flag.Int(CfgGossipPort, 14666, "tcp port for gossip connection")
} }
...@@ -15,19 +15,20 @@ import ( ...@@ -15,19 +15,20 @@ import (
"github.com/iotaledger/goshimmer/plugins/messagelayer" "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) { func configure(*node.Plugin) {
log = logger.NewLogger(name) log = logger.NewLogger(pluginName)
configureGossip() configureGossip()
configureEvents() configureEvents()
} }
func run(*node.Plugin) { 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) log.Errorf("Failed to start as daemon: %s", err)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment