Skip to content
Snippets Groups Projects
Unverified Commit c133ef18 authored by Wolfgang Welz's avatar Wolfgang Welz Committed by GitHub
Browse files

Fix simple linter warnings (#562)

parent 0126e719
No related branches found
No related tags found
No related merge requests found
Showing
with 46 additions and 54 deletions
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"time" "time"
faucet "github.com/iotaledger/goshimmer/dapps/faucet/packages" faucet "github.com/iotaledger/goshimmer/dapps/faucet/packages"
"github.com/iotaledger/goshimmer/dapps/faucet/packages/payload" faucetpayload "github.com/iotaledger/goshimmer/dapps/faucet/packages/payload"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/packages/shutdown"
......
...@@ -29,7 +29,7 @@ const ( ...@@ -29,7 +29,7 @@ const (
var ( var (
// App is the "plugin" instance of the network delay application. // App is the "plugin" instance of the network delay application.
app *node.Plugin app *node.Plugin
once sync.Once once sync.Once
// log holds a reference to the logger used by this app. // log holds a reference to the logger used by this app.
...@@ -44,8 +44,8 @@ var ( ...@@ -44,8 +44,8 @@ var (
// App gets the plugin instance. // App gets the plugin instance.
func App() *node.Plugin { func App() *node.Plugin {
once.Do(func () { once.Do(func() {
app = node.NewPlugin(PluginName, node.Disabled, configure) app = node.NewPlugin(PluginName, node.Disabled, configure)
}) })
return app return app
} }
......
...@@ -2,11 +2,10 @@ package transaction ...@@ -2,11 +2,10 @@ package transaction
import ( import (
"fmt" "fmt"
"github.com/mr-tron/base58"
"github.com/iotaledger/hive.go/marshalutil"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/hive.go/marshalutil"
"github.com/mr-tron/base58"
) )
// OutputID is the data type that represents the identifier for a Output. // OutputID is the data type that represents the identifier for a Output.
......
...@@ -2,13 +2,12 @@ package transaction ...@@ -2,13 +2,12 @@ package transaction
import ( import (
"bytes" "bytes"
"github.com/iotaledger/hive.go/marshalutil"
"sort" "sort"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/goshimmer/packages/binary/datastructure/orderedmap"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance" "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/goshimmer/packages/binary/datastructure/orderedmap"
"github.com/iotaledger/hive.go/marshalutil"
) )
// Outputs represents a list of Outputs that are part of a transaction. // Outputs represents a list of Outputs that are part of a transaction.
......
...@@ -29,10 +29,6 @@ func peerAndErrorCaller(handler interface{}, params ...interface{}) { ...@@ -29,10 +29,6 @@ func peerAndErrorCaller(handler interface{}, params ...interface{}) {
handler.(func(*peer.Peer, error))(params[0].(*peer.Peer), params[1].(error)) handler.(func(*peer.Peer, error))(params[0].(*peer.Peer), params[1].(error))
} }
func peerCaller(handler interface{}, params ...interface{}) {
handler.(func(*peer.Peer))(params[0].(*peer.Peer))
}
func neighborCaller(handler interface{}, params ...interface{}) { func neighborCaller(handler interface{}, params ...interface{}) {
handler.(func(*Neighbor))(params[0].(*Neighbor)) handler.(func(*Neighbor))(params[0].(*Neighbor))
} }
......
...@@ -32,11 +32,10 @@ func init() { ...@@ -32,11 +32,10 @@ func init() {
var ( var (
// plugin is the plugin instance of the analysis client plugin. // plugin is the plugin instance of the analysis client plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
conn *Connector conn *Connector
connLock sync.Mutex
) )
// Plugin gets the plugin instance // Plugin gets the plugin instance
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"encoding/gob" "encoding/gob"
"errors" "errors"
"github.com/iotaledger/goshimmer/packages/vote" "github.com/iotaledger/goshimmer/packages/vote"
"github.com/iotaledger/hive.go/protocol/message" "github.com/iotaledger/hive.go/protocol/message"
"github.com/iotaledger/hive.go/protocol/tlv" "github.com/iotaledger/hive.go/protocol/tlv"
...@@ -30,7 +31,7 @@ type FPCHeartbeat struct { ...@@ -30,7 +31,7 @@ type FPCHeartbeat struct {
func FPCHeartbeatMessageDefinition() *message.Definition { func FPCHeartbeatMessageDefinition() *message.Definition {
// fpcHeartbeatMessageDefinition defines a heartbeat message's format. // fpcHeartbeatMessageDefinition defines a heartbeat message's format.
var fpcHeartbeatMessageDefinition *message.Definition var fpcHeartbeatMessageDefinition *message.Definition
fpcHeartBeatOnce.Do(func(){ fpcHeartBeatOnce.Do(func() {
fpcHeartbeatMessageDefinition = &message.Definition{ fpcHeartbeatMessageDefinition = &message.Definition{
ID: MessageTypeFPCHeartbeat, ID: MessageTypeFPCHeartbeat,
MaxBytesLength: 65535, MaxBytesLength: 65535,
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"encoding/binary" "encoding/binary"
"errors" "errors"
"fmt" "fmt"
"github.com/iotaledger/hive.go/protocol/message" "github.com/iotaledger/hive.go/protocol/message"
"github.com/iotaledger/hive.go/protocol/tlv" "github.com/iotaledger/hive.go/protocol/tlv"
) )
...@@ -31,7 +32,6 @@ const ( ...@@ -31,7 +32,6 @@ const (
HeartbeatMaxOutboundPeersCount*sha256.Size + HeartbeatMaxInboundPeersCount*sha256.Size HeartbeatMaxOutboundPeersCount*sha256.Size + HeartbeatMaxInboundPeersCount*sha256.Size
) )
// Heartbeat represents a heartbeat packet. // Heartbeat represents a heartbeat packet.
type Heartbeat struct { type Heartbeat struct {
// The ID of the node who sent the heartbeat. // The ID of the node who sent the heartbeat.
...@@ -46,10 +46,10 @@ type Heartbeat struct { ...@@ -46,10 +46,10 @@ type Heartbeat struct {
} }
// HeartBeatMessageDefinition gets the heartbeatMessageDefinition. // HeartBeatMessageDefinition gets the heartbeatMessageDefinition.
func HeartBeatMessageDefinition() *message.Definition{ func HeartBeatMessageDefinition() *message.Definition {
// heartbeatMessageDefinition defines a heartbeat message's format. // heartbeatMessageDefinition defines a heartbeat message's format.
var heartbeatMessageDefinition *message.Definition var heartbeatMessageDefinition *message.Definition
heartBeatOnce.Do(func(){ heartBeatOnce.Do(func() {
heartbeatMessageDefinition = &message.Definition{ heartbeatMessageDefinition = &message.Definition{
ID: MessageTypeHeartbeat, ID: MessageTypeHeartbeat,
MaxBytesLength: uint16(HeartbeatPacketMaxSize), MaxBytesLength: uint16(HeartbeatPacketMaxSize),
......
...@@ -19,7 +19,7 @@ const PluginName = "Autopeering" ...@@ -19,7 +19,7 @@ const PluginName = "Autopeering"
var ( var (
// plugin is the plugin instance of the autopeering plugin. // plugin is the plugin instance of the autopeering plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
) )
...@@ -27,7 +27,7 @@ var ( ...@@ -27,7 +27,7 @@ var (
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
func Plugin() *node.Plugin { func Plugin() *node.Plugin {
once.Do(func() { once.Do(func() {
plugin = node.NewPlugin(PluginName, node.Enabled, configure, run) plugin = node.NewPlugin(PluginName, node.Enabled, configure, run)
}) })
return plugin return plugin
} }
......
...@@ -13,7 +13,7 @@ const PluginName = "Banner" ...@@ -13,7 +13,7 @@ const PluginName = "Banner"
var ( var (
// plugin is the plugin instance of the banner plugin. // plugin is the plugin instance of the banner plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
) )
const ( const (
...@@ -27,7 +27,7 @@ const ( ...@@ -27,7 +27,7 @@ const (
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
func Plugin() *node.Plugin { func Plugin() *node.Plugin {
once.Do(func() { once.Do(func() {
plugin = node.NewPlugin(PluginName, node.Disabled, configure, run) plugin = node.NewPlugin(PluginName, node.Disabled, configure, run)
}) })
return plugin return plugin
} }
......
...@@ -35,14 +35,14 @@ func init() { ...@@ -35,14 +35,14 @@ func init() {
var ( var (
// plugin is the plugin instance of the bootstrap plugin. // plugin is the plugin instance of the bootstrap plugin.
plugin *node.Plugin plugin *node.Plugin
once goSync.Once once goSync.Once
log *logger.Logger log *logger.Logger
) )
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
func Plugin() *node.Plugin { func Plugin() *node.Plugin {
once.Do(func() { once.Do(func() {
plugin = node.NewPlugin(PluginName, node.Disabled, configure, run) plugin = node.NewPlugin(PluginName, node.Disabled, configure, run)
}) })
return plugin return plugin
} }
......
...@@ -5,11 +5,10 @@ import ( ...@@ -5,11 +5,10 @@ import (
"os" "os"
"sync" "sync"
"github.com/iotaledger/goshimmer/plugins/banner"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
"github.com/iotaledger/goshimmer/plugins/banner"
) )
// PluginName is the name of the CLI plugin. // PluginName is the name of the CLI plugin.
...@@ -18,7 +17,7 @@ const PluginName = "CLI" ...@@ -18,7 +17,7 @@ const PluginName = "CLI"
var ( var (
// plugin is the plugin instance of the CLI plugin. // plugin is the plugin instance of the CLI plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
version = flag.BoolP("version", "v", false, "Prints the GoShimmer version") version = flag.BoolP("version", "v", false, "Prints the GoShimmer version")
) )
......
...@@ -27,7 +27,7 @@ var ( ...@@ -27,7 +27,7 @@ var (
skipConfigAvailable = flag.Bool("skip-config", false, "Skip config file availability check") skipConfigAvailable = flag.Bool("skip-config", false, "Skip config file availability check")
// Node is viper // Node is viper
_node *viper.Viper _node *viper.Viper
nodeOnce sync.Once nodeOnce sync.Once
) )
...@@ -57,7 +57,6 @@ func init() { ...@@ -57,7 +57,6 @@ func init() {
_node = Node() _node = Node()
plugin = Plugin() plugin = Plugin()
plugin.Events.Init.Attach(events.NewClosure(func(*node.Plugin) { plugin.Events.Init.Attach(events.NewClosure(func(*node.Plugin) {
if err := fetch(false); err != nil { if err := fetch(false); err != nil {
if !*skipConfigAvailable { if !*skipConfigAvailable {
......
...@@ -33,7 +33,7 @@ const PluginName = "Dashboard" ...@@ -33,7 +33,7 @@ const PluginName = "Dashboard"
var ( var (
// plugin is the plugin instance of the dashboard plugin. // plugin is the plugin instance of the dashboard plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
server *echo.Echo server *echo.Echo
......
...@@ -20,11 +20,11 @@ const PluginName = "DRNG" ...@@ -20,11 +20,11 @@ const PluginName = "DRNG"
var ( var (
// plugin is the plugin instance of the DRNG plugin. // plugin is the plugin instance of the DRNG plugin.
plugin *node.Plugin plugin *node.Plugin
pluginOnce sync.Once pluginOnce sync.Once
instance *drng.DRNG instance *drng.DRNG
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
) )
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
...@@ -35,7 +35,6 @@ func Plugin() *node.Plugin { ...@@ -35,7 +35,6 @@ func Plugin() *node.Plugin {
return plugin return plugin
} }
func configure(_ *node.Plugin) { func configure(_ *node.Plugin) {
configureEvents() configureEvents()
} }
......
package gossip package gossip
import ( import (
"sync"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/tangle"
"github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip"
...@@ -13,7 +15,6 @@ import ( ...@@ -13,7 +15,6 @@ import (
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"sync"
) )
// PluginName is the name of the gossip plugin. // PluginName is the name of the gossip plugin.
...@@ -22,7 +23,7 @@ const PluginName = "Gossip" ...@@ -22,7 +23,7 @@ const PluginName = "Gossip"
var ( var (
// plugin is the plugin instance of the gossip plugin. // plugin is the plugin instance of the gossip plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
) )
...@@ -35,7 +36,6 @@ func Plugin() *node.Plugin { ...@@ -35,7 +36,6 @@ func Plugin() *node.Plugin {
return plugin return plugin
} }
func configure(*node.Plugin) { func configure(*node.Plugin) {
log = logger.NewLogger(PluginName) log = logger.NewLogger(PluginName)
......
...@@ -23,9 +23,9 @@ const WaitToKillTimeInSeconds = 60 ...@@ -23,9 +23,9 @@ const WaitToKillTimeInSeconds = 60
var ( var (
// plugin is the plugin instance of the graceful shutdown plugin. // plugin is the plugin instance of the graceful shutdown plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
gracefulStop chan os.Signal gracefulStop chan os.Signal
) )
...@@ -45,8 +45,11 @@ func Plugin() *node.Plugin { ...@@ -45,8 +45,11 @@ func Plugin() *node.Plugin {
log.Warnf("Received shutdown request - waiting (max %d) to finish processing ...", WaitToKillTimeInSeconds) log.Warnf("Received shutdown request - waiting (max %d) to finish processing ...", WaitToKillTimeInSeconds)
go func() { go func() {
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
start := time.Now() start := time.Now()
for x := range time.Tick(1 * time.Second) { for x := range ticker.C {
secondsSinceStart := x.Sub(start).Seconds() secondsSinceStart := x.Sub(start).Seconds()
if secondsSinceStart <= WaitToKillTimeInSeconds { if secondsSinceStart <= WaitToKillTimeInSeconds {
...@@ -71,7 +74,6 @@ func Plugin() *node.Plugin { ...@@ -71,7 +74,6 @@ func Plugin() *node.Plugin {
return plugin return plugin
} }
// ShutdownWithError prints out an error message and shuts down the default daemon instance. // ShutdownWithError prints out an error message and shuts down the default daemon instance.
func ShutdownWithError(err error) { func ShutdownWithError(err error) {
log.Error(err) log.Error(err)
......
...@@ -17,8 +17,7 @@ const PluginName = "Issuer" ...@@ -17,8 +17,7 @@ const PluginName = "Issuer"
var ( var (
// plugin is the plugin instance of the issuer plugin. // plugin is the plugin instance of the issuer plugin.
plugin *node.Plugin plugin *node.Plugin
once goSync.Once once goSync.Once
) )
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
......
package logger package logger
import ( import (
"sync"
"github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"sync"
) )
// PluginName is the name of the logger plugin. // PluginName is the name of the logger plugin.
...@@ -14,7 +15,7 @@ const PluginName = "Logger" ...@@ -14,7 +15,7 @@ const PluginName = "Logger"
var ( var (
// plugin is the plugin instance of the logger plugin. // plugin is the plugin instance of the logger plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
) )
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
...@@ -25,7 +26,6 @@ func Plugin() *node.Plugin { ...@@ -25,7 +26,6 @@ func Plugin() *node.Plugin {
return plugin return plugin
} }
// Init triggers the Init event. // Init triggers the Init event.
func Init() { func Init() {
plugin.Events.Init.Trigger(plugin) plugin.Events.Init.Trigger(plugin)
......
...@@ -20,7 +20,7 @@ const PluginName = "PortCheck" ...@@ -20,7 +20,7 @@ const PluginName = "PortCheck"
var ( var (
// plugin is the plugin instance of the port check plugin. // plugin is the plugin instance of the port check plugin.
plugin *node.Plugin plugin *node.Plugin
once sync.Once once sync.Once
log *logger.Logger log *logger.Logger
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment