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
|
||||
case <-evtRelayUnsubscribed.Out():
|
||||
case <-evtRelaySubscribed.Out():
|
||||
rs, err := protocol.TopicsToRelayShards(w.Relay().Topics()...)
|
||||
topics := w.Relay().Topics()
|
||||
rs, err := protocol.TopicsToRelayShards(topics...)
|
||||
if err != nil {
|
||||
w.log.Warn("could not set ENR shard info", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
if len(rs) > 1 {
|
||||
w.log.Warn("use sharded topics within the same cluster")
|
||||
continue
|
||||
if len(rs) > 0 {
|
||||
if len(rs) > 1 {
|
||||
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 {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const MaxShardIndex = uint16(1023)
|
||||
|
@ -76,6 +77,10 @@ func TopicsToRelayShards(topic ...string) ([]RelayShards, error) {
|
|||
result := make([]RelayShards, 0)
|
||||
dict := make(map[uint16]map[uint16]struct{})
|
||||
for _, t := range topic {
|
||||
if !strings.HasPrefix(t, StaticShardingPubsubTopicPrefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
var ps StaticShardingPubsubTopic
|
||||
err := ps.Parse(t)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue