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(
database.PLUGIN,
autopeering.Plugin,
messagelayer.PLUGIN,
gossip.PLUGIN,
gossip.Plugin,
gracefulshutdown.PLUGIN,
metrics.PLUGIN,
drng.PLUGIN,
......
......@@ -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)),
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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")
}
......@@ -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)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment