mirror of https://github.com/status-im/go-waku.git
fix: warning message format when using static shards and named shards at same time
This commit is contained in:
parent
ca297713fa
commit
8cac406a4c
|
@ -305,15 +305,27 @@ func (w *WakuNode) watchTopicShards(ctx context.Context) error {
|
||||||
return
|
return
|
||||||
case <-evtRelayUnsubscribed.Out():
|
case <-evtRelayUnsubscribed.Out():
|
||||||
case <-evtRelaySubscribed.Out():
|
case <-evtRelaySubscribed.Out():
|
||||||
rs, err := protocol.TopicsToRelayShards(w.Relay().Topics()...)
|
topics := w.Relay().Topics()
|
||||||
|
rs, err := protocol.TopicsToRelayShards(topics...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.log.Warn("could not set ENR shard info", zap.Error(err))
|
w.log.Warn("could not set ENR shard info", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rs) > 1 {
|
if len(rs) > 0 {
|
||||||
w.log.Warn("use sharded topics within the same cluster")
|
if len(rs) > 1 {
|
||||||
continue
|
w.log.Warn("could not set ENR shard info", zap.String("error", "use sharded topics within the same cluster"))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
tcount := 0
|
||||||
|
for _, r := range rs {
|
||||||
|
tcount += len(r.Indices)
|
||||||
|
}
|
||||||
|
if tcount != len(topics) {
|
||||||
|
w.log.Warn("could not set ENR shard info", zap.String("error", "can't use a mix of static shards and named shards"))
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rs) == 1 {
|
if len(rs) == 1 {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxShardIndex = uint16(1023)
|
const MaxShardIndex = uint16(1023)
|
||||||
|
@ -76,6 +77,10 @@ func TopicsToRelayShards(topic ...string) ([]RelayShards, error) {
|
||||||
result := make([]RelayShards, 0)
|
result := make([]RelayShards, 0)
|
||||||
dict := make(map[uint16]map[uint16]struct{})
|
dict := make(map[uint16]map[uint16]struct{})
|
||||||
for _, t := range topic {
|
for _, t := range topic {
|
||||||
|
if !strings.HasPrefix(t, StaticShardingPubsubTopicPrefix) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var ps StaticShardingPubsubTopic
|
var ps StaticShardingPubsubTopic
|
||||||
err := ps.Parse(t)
|
err := ps.Parse(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue