mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-13 07:14:10 +00:00
fix: allow mixing named and static shards
This commit is contained in:
parent
5fcfbb9897
commit
84fa332e1c
@ -453,10 +453,17 @@ func (d *DiscoveryV5) peerLoop(ctx context.Context) error {
|
||||
}
|
||||
|
||||
nodeRS, err := wenr.RelaySharding(n.Record())
|
||||
if err != nil || nodeRS == nil {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if nodeRS == nil {
|
||||
// TODO: Node has no shard registered.
|
||||
// Since for now, status-go uses both mixed static and named shards, we assume the node is valid
|
||||
// Once status-go uses only static shards, we can't return true anymore.
|
||||
return true
|
||||
}
|
||||
|
||||
if nodeRS.Cluster != localRS.Cluster {
|
||||
return false
|
||||
}
|
||||
|
@ -315,22 +315,17 @@ func (w *WakuNode) watchTopicShards(ctx context.Context) error {
|
||||
|
||||
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"))
|
||||
w.log.Warn("could not set ENR shard info", zap.String("error", "multiple clusters found, use sharded topics within the same cluster"))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if len(rs) == 1 {
|
||||
w.log.Info("updating advertised relay shards in ENR")
|
||||
if len(rs[0].Indices) != len(topics) {
|
||||
w.log.Warn("A mix of named and static shards found. ENR shard will contain only the following shards", zap.Any("shards", rs[0]))
|
||||
}
|
||||
|
||||
err = wenr.Update(w.localNode, wenr.WithWakuRelaySharding(rs[0]))
|
||||
if err != nil {
|
||||
w.log.Warn("could not set ENR shard info", zap.Error(err))
|
||||
|
@ -20,8 +20,8 @@ const ClusterIndex = 1
|
||||
const GenerationZeroShardsCount = 8
|
||||
|
||||
type RelayShards struct {
|
||||
Cluster uint16
|
||||
Indices []uint16
|
||||
Cluster uint16 `json:"cluster"`
|
||||
Indices []uint16 `json:"indices"`
|
||||
}
|
||||
|
||||
func NewRelayShards(cluster uint16, indices ...uint16) (RelayShards, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user