From 4ef0c75ded00b5340eeda969898642a2aff523fe Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 2 Jan 2024 18:04:43 +0530 Subject: [PATCH] fix: use node's clusterId when adding peer from admin REST API & don't subscribe to default pubsub topic for non-zero clusterID (#973) --- cmd/waku/node.go | 2 +- cmd/waku/server/rest/admin.go | 2 +- waku/v2/node/wakunode2.go | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/waku/node.go b/cmd/waku/node.go index 92da475e..648fc213 100644 --- a/cmd/waku/node.go +++ b/cmd/waku/node.go @@ -478,7 +478,7 @@ func processTopics(options NodeOptions) (map[string][]string, error) { pubSubTopicMap[pTopic.String()] = append(pubSubTopicMap[pTopic.String()], cTopic) } //If no topics are passed, then use default waku topic. - if len(pubSubTopicMap) == 0 { + if len(pubSubTopicMap) == 0 && options.ClusterID == 0 { pubSubTopicMap[relay.DefaultWakuTopic] = []string{} } diff --git a/cmd/waku/server/rest/admin.go b/cmd/waku/server/rest/admin.go index 1e719e1d..f945c681 100644 --- a/cmd/waku/server/rest/admin.go +++ b/cmd/waku/server/rest/admin.go @@ -105,7 +105,7 @@ func (a *AdminService) postV1Peer(w http.ResponseWriter, req *http.Request) { } for _, shard := range pInfo.Shards { - topic := waku_proto.NewStaticShardingPubsubTopic(waku_proto.ClusterIndex, uint16(shard)) + topic := waku_proto.NewStaticShardingPubsubTopic(a.node.ClusterID(), uint16(shard)) topics = append(topics, topic.String()) } diff --git a/waku/v2/node/wakunode2.go b/waku/v2/node/wakunode2.go index a499ab71..5faf5435 100644 --- a/waku/v2/node/wakunode2.go +++ b/waku/v2/node/wakunode2.go @@ -978,3 +978,7 @@ func GetDiscv5Option(dnsDiscoveredNodes []dnsdisc.DiscoveredNode, discv5Nodes [] return WithDiscoveryV5(port, bootnodes, autoUpdate), nil } + +func (w *WakuNode) ClusterID() uint16 { + return w.opts.clusterID +}