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
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o build/waku waku.go
|
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 {
|
if len(staticnodes) > 0 {
|
||||||
for _, n := range staticnodes {
|
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 {
|
} else {
|
||||||
if len(lightpushnodes) > 0 {
|
if len(lightpushnodes) > 0 {
|
||||||
for _, n := range lightpushnodes {
|
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 {
|
} else {
|
||||||
if len(filternodes) > 0 {
|
if len(filternodes) > 0 {
|
||||||
for _, n := range filternodes {
|
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.opts.store.Start(w.ctx, w.host, peerChan)
|
||||||
w.peerListeners = append(w.peerListeners, peerChan)
|
w.peerListeners = append(w.peerListeners, peerChan)
|
||||||
w.opts.store.Resume(string(relay.GetTopic(nil)), nil)
|
w.opts.store.Resume(string(relay.GetTopic(nil)), nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WakuNode) AddStorePeer(address string) (*peer.ID, error) {
|
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 _, rId := range idsToRemove {
|
||||||
for id, _ := range node.filters {
|
for id := range node.filters {
|
||||||
if id == rId {
|
if id == rId {
|
||||||
delete(node.filters, id)
|
delete(node.filters, id)
|
||||||
break
|
break
|
||||||
|
@ -694,8 +693,7 @@ func (w *WakuNode) DialPeer(address string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
w.host.Connect(w.ctx, *info)
|
return w.host.Connect(w.ctx, *info)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WakuNode) ClosePeerByAddress(address string) error {
|
func (w *WakuNode) ClosePeerByAddress(address string) error {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p-core/crypto"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr-net"
|
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"
|
"github.com/status-im/go-waku/waku/v2/protocol/store"
|
||||||
wakurelay "github.com/status-im/go-wakurelay-pubsub"
|
wakurelay "github.com/status-im/go-wakurelay-pubsub"
|
||||||
)
|
)
|
||||||
|
@ -30,7 +29,7 @@ type WakuNodeParameters struct {
|
||||||
enableStore bool
|
enableStore bool
|
||||||
storeMsgs bool
|
storeMsgs bool
|
||||||
store *store.WakuStore
|
store *store.WakuStore
|
||||||
filter *filter.WakuFilter
|
// filter *filter.WakuFilter
|
||||||
|
|
||||||
keepAliveInterval time.Duration
|
keepAliveInterval time.Duration
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ func (wakuLP *WakuLightPush) onRequest(s network.Stream) {
|
||||||
err = writer.WriteMsg(responsePushRPC)
|
err = writer.WriteMsg(responsePushRPC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("error writing response", err)
|
log.Error("error writing response", err)
|
||||||
s.Reset()
|
_ = s.Reset()
|
||||||
} else {
|
} else {
|
||||||
log.Info(fmt.Sprintf("%s: response sent to %s", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String()))
|
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()
|
w.topicsMutex.Lock()
|
||||||
|
|
||||||
var result []Topic
|
var result []Topic
|
||||||
for topic, _ := range w.topics {
|
for topic := range w.topics {
|
||||||
result = append(result, topic)
|
result = append(result, topic)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
@ -109,7 +109,7 @@ func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, topic
|
||||||
// Publish a `WakuMessage` to a PubSub topic.
|
// Publish a `WakuMessage` to a PubSub topic.
|
||||||
|
|
||||||
if w.pubsub == nil {
|
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 {
|
if message == nil {
|
||||||
|
|
|
@ -348,7 +348,7 @@ func (store *WakuStore) onRequest(s network.Stream) {
|
||||||
err = writer.WriteMsg(historyResponseRPC)
|
err = writer.WriteMsg(historyResponseRPC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("error writing response", err)
|
log.Error("error writing response", err)
|
||||||
s.Reset()
|
_ = s.Reset()
|
||||||
} else {
|
} else {
|
||||||
log.Info(fmt.Sprintf("%s: Response sent to %s", s.Conn().LocalPeer().String(), s.Conn().RemotePeer().String()))
|
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.Close()
|
||||||
defer connOpt.Reset()
|
defer func() {
|
||||||
|
_ = connOpt.Reset()
|
||||||
|
}()
|
||||||
|
|
||||||
historyRequest := &pb.HistoryRPC{Query: q, RequestId: hex.EncodeToString(requestId)}
|
historyRequest := &pb.HistoryRPC{Query: q, RequestId: hex.EncodeToString(requestId)}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue