mirror of https://github.com/status-im/go-waku.git
adding lint target and fixing lint issues (#38)
This commit is contained in:
parent
73bedde63c
commit
748e738d9a
6
Makefile
6
Makefile
|
@ -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
|
15
waku/node.go
15
waku/node.go
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)}
|
||||
|
||||
|
|
Loading…
Reference in New Issue