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