mirror of https://github.com/status-im/go-waku.git
fix: lint
This commit is contained in:
parent
97973e3226
commit
e393b68ab7
2
Makefile
2
Makefile
|
@ -61,7 +61,7 @@ vendor:
|
|||
|
||||
lint-install:
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
|
||||
bash -s -- -b $(shell ${GOBIN} env GOPATH)/bin v1.46.2
|
||||
bash -s -- -b $(shell ${GOBIN} env GOPATH)/bin v1.50.0
|
||||
|
||||
lint:
|
||||
@echo "lint"
|
||||
|
|
|
@ -23,6 +23,7 @@ type PrivateService struct {
|
|||
log *zap.Logger
|
||||
|
||||
messages map[string][]*pb.WakuMessage
|
||||
cacheCapacity int
|
||||
messagesMutex sync.RWMutex
|
||||
|
||||
runner *runnerService
|
||||
|
@ -57,9 +58,10 @@ type AsymmetricMessagesArgs struct {
|
|||
PrivateKey string `json:"privateKey"`
|
||||
}
|
||||
|
||||
func NewPrivateService(node *node.WakuNode, log *zap.Logger) *PrivateService {
|
||||
func NewPrivateService(node *node.WakuNode, cacheCapacity int, log *zap.Logger) *PrivateService {
|
||||
p := &PrivateService{
|
||||
node: node,
|
||||
cacheCapacity: cacheCapacity,
|
||||
messages: make(map[string][]*pb.WakuMessage),
|
||||
log: log.Named("private"),
|
||||
}
|
||||
|
@ -75,6 +77,11 @@ func (p *PrivateService) addEnvelope(envelope *protocol.Envelope) {
|
|||
p.messages[envelope.PubsubTopic()] = make([]*pb.WakuMessage, 0)
|
||||
}
|
||||
|
||||
// Keep a specific max number of messages per topic
|
||||
if len(p.messages[envelope.PubsubTopic()]) >= p.cacheCapacity {
|
||||
p.messages[envelope.PubsubTopic()] = p.messages[envelope.PubsubTopic()][1:]
|
||||
}
|
||||
|
||||
p.messages[envelope.PubsubTopic()] = append(p.messages[envelope.PubsubTopic()], envelope.Message())
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ func makePrivateService(t *testing.T) *PrivateService {
|
|||
err = n.Start()
|
||||
require.NoError(t, err)
|
||||
|
||||
return NewPrivateService(n, utils.Logger())
|
||||
return NewPrivateService(n, 30, utils.Logger())
|
||||
}
|
||||
|
||||
func TestGetV1SymmetricKey(t *testing.T) {
|
||||
|
|
|
@ -72,7 +72,7 @@ func NewWakuRpc(node *node.WakuNode, address string, port int, enableAdmin bool,
|
|||
}
|
||||
|
||||
if enablePrivate {
|
||||
privateService := NewPrivateService(node, log)
|
||||
privateService := NewPrivateService(node, cacheCapacity, log)
|
||||
err = s.RegisterService(privateService, "Private")
|
||||
if err != nil {
|
||||
wrpc.log.Error("registering private service", zap.Error(err))
|
||||
|
|
Loading…
Reference in New Issue