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,17 +305,29 @@ 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) > 0 {
|
||||
if len(rs) > 1 {
|
||||
w.log.Warn("use sharded topics within the same cluster")
|
||||
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 {
|
||||
w.log.Info("updating advertised relay shards in ENR")
|
||||
err = wenr.Update(w.localNode, wenr.WithWakuRelaySharding(rs[0]))
|
||||
|
|
|
@ -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