Skip to content
Snippets Groups Projects
Unverified Commit c4935568 authored by Angelo Capossele's avatar Angelo Capossele Committed by GitHub
Browse files

Merge pull request #352 from iotaledger/chores/gossip-linter

Fixes gossip plugin linter warnings.
parents dcfd8db9 907a3861
No related branches found
No related tags found
No related merge requests found
......@@ -189,7 +189,7 @@ func neighborMetrics() []neighbormetric {
stats := []neighbormetric{}
// gossip plugin might be disabled
neighbors := gossip.GetAllNeighbors()
neighbors := gossip.Neighbors()
if neighbors == nil {
return stats
}
......
......@@ -5,16 +5,15 @@ import (
"net"
"strconv"
"github.com/iotaledger/hive.go/autopeering/peer/service"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/netutil"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
gp "github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/gossip/server"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/autopeering/peer/service"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/netutil"
)
var (
......@@ -27,9 +26,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 {
......@@ -72,17 +71,18 @@ func start(shutdownSignal <-chan struct{}) {
}
// 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")
}
package gossip
import (
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
"github.com/iotaledger/hive.go/autopeering/peer"
"github.com/iotaledger/hive.go/autopeering/selection"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/packages/gossip"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/messagelayer"
)
// PluginName is the name of the gossip plugin.
......
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