adding lint target and fixing lint issues (#38)

This commit is contained in:
RichΛrd 2021-07-29 08:40:54 -04:00 committed by GitHub
parent 73bedde63c
commit 748e738d9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 15 deletions

View File

@ -1,6 +1,10 @@
.PHONY: all build
.PHONY: all build lint
all: build
build:
go build -o build/waku waku.go
lint:
@echo "lint"
@golangci-lint --exclude=SA1019 run ./... --deadline=5m

View File

@ -179,7 +179,10 @@ var rootCmd = &cobra.Command{
if len(staticnodes) > 0 {
for _, n := range staticnodes {
go wakuNode.DialPeer(n)
go func(node string) {
err = wakuNode.DialPeer(node)
checkError(err, "Error dialing peer")
}(n)
}
}
@ -188,7 +191,10 @@ var rootCmd = &cobra.Command{
} else {
if len(lightpushnodes) > 0 {
for _, n := range lightpushnodes {
go wakuNode.AddLightPushPeer(n)
go func(node string) {
_, err = wakuNode.AddLightPushPeer(node)
checkError(err, "Error adding lightpush peer")
}(n)
}
}
}
@ -198,7 +204,10 @@ var rootCmd = &cobra.Command{
} else {
if len(filternodes) > 0 {
for _, n := range filternodes {
go wakuNode.AddFilterPeer(n)
go func(node string) {
_, err = wakuNode.AddFilterPeer(node)
checkError(err, "Error adding filter peer")
}(n)
}
}
}

View File

@ -377,7 +377,6 @@ func (w *WakuNode) startStore() {
w.opts.store.Start(w.ctx, w.host, peerChan)
w.peerListeners = append(w.peerListeners, peerChan)
w.opts.store.Resume(string(relay.GetTopic(nil)), nil)
}
func (w *WakuNode) AddStorePeer(address string) (*peer.ID, error) {
@ -627,7 +626,7 @@ func (node *WakuNode) UnsubscribeFilter(ctx context.Context, request pb.FilterRe
}
for _, rId := range idsToRemove {
for id, _ := range node.filters {
for id := range node.filters {
if id == rId {
delete(node.filters, id)
break
@ -694,8 +693,7 @@ func (w *WakuNode) DialPeer(address string) error {
return err
}
w.host.Connect(w.ctx, *info)
return nil
return w.host.Connect(w.ctx, *info)
}
func (w *WakuNode) ClosePeerByAddress(address string) error {

View File

@ -10,7 +10,6 @@ import (
"github.com/libp2p/go-libp2p-core/crypto"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
"github.com/status-im/go-waku/waku/v2/protocol/filter"
"github.com/status-im/go-waku/waku/v2/protocol/store"
wakurelay "github.com/status-im/go-wakurelay-pubsub"
)
@ -30,7 +29,7 @@ type WakuNodeParameters struct {
enableStore bool
storeMsgs bool
store *store.WakuStore
filter *filter.WakuFilter
// filter *filter.WakuFilter
keepAliveInterval time.Duration

View File

@ -91,7 +91,7 @@ func (wakuLP *WakuLightPush) onRequest(s network.Stream) {
err = writer.WriteMsg(responsePushRPC)
if err != nil {
log.Error("error writing response", err)
s.Reset()
_ = s.Reset()
} else {
log.Info(fmt.Sprintf("%s: response sent to %s", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String()))
}

View File

@ -56,7 +56,7 @@ func (w *WakuRelay) Topics() []Topic {
w.topicsMutex.Lock()
var result []Topic
for topic, _ := range w.topics {
for topic := range w.topics {
result = append(result, topic)
}
return result
@ -109,7 +109,7 @@ func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, topic
// Publish a `WakuMessage` to a PubSub topic.
if w.pubsub == nil {
return nil, errors.New("PubSub hasn't been set.")
return nil, errors.New("PubSub hasn't been set")
}
if message == nil {

View File

@ -348,7 +348,7 @@ func (store *WakuStore) onRequest(s network.Stream) {
err = writer.WriteMsg(historyResponseRPC)
if err != nil {
log.Error("error writing response", err)
s.Reset()
_ = s.Reset()
} else {
log.Info(fmt.Sprintf("%s: Response sent to %s", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String()))
}
@ -477,7 +477,9 @@ func (store *WakuStore) queryFrom(ctx context.Context, q *pb.HistoryQuery, selec
}
defer connOpt.Close()
defer connOpt.Reset()
defer func() {
_ = connOpt.Reset()
}()
historyRequest := &pb.HistoryRPC{Query: q, RequestId: hex.EncodeToString(requestId)}