Skip to content

Commit

Permalink
fix: setup shards
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Nov 20, 2024
1 parent dd82c24 commit 474fe3f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
21 changes: 16 additions & 5 deletions cmd/waku/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,6 @@ func Execute(options NodeOptions) error {
nodeOpts = append(nodeOpts, discv5Opts)
}

wakuNode, err := node.New(nodeOpts...)
if err != nil {
return fmt.Errorf("could not instantiate waku: %w", err)
}

//Process pubSub and contentTopics specified and arrive at all corresponding pubSubTopics
pubSubTopicMap, err := processTopics(options)
if err != nil {
Expand All @@ -325,6 +320,22 @@ func Execute(options NodeOptions) error {
pubSubTopicMapKeys = append(pubSubTopicMapKeys, k)
}

rs, err := wprotocol.TopicsToRelayShards(pubSubTopicMapKeys...)
if err == nil {
if len(rs) == 1 {
nodeOpts = append(nodeOpts, node.WithShards(rs[0].ShardIDs))
} else {
logger.Warn("could not set ENR shard info", zap.String("error", "invalid number of clusters found"), zap.Int("numClusters", len(rs)))
}
} else {
logger.Warn("could not obtain list of shards", zap.Error(err))
}

wakuNode, err := node.New(nodeOpts...)
if err != nil {
return fmt.Errorf("could not instantiate waku: %w", err)
}

if err = wakuNode.Start(ctx); err != nil {
return nonRecoverError(err)
}
Expand Down
18 changes: 11 additions & 7 deletions waku/v2/node/wakunode2.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,17 @@ func (w *WakuNode) Start(ctx context.Context) error {
if err != nil {
return err
}
//TODO: setting this up temporarily to improve connectivity success for lightNode in status.
//This will have to be removed or changed with community sharding will be implemented.
if w.opts.shards != nil {
err = w.SetRelayShards(*w.opts.shards)
if err != nil {
return err
}
}

//TODO: setting this up temporarily to improve connectivity success for lightNode
// in status. Also, when executing go-waku service-node as a lightclient
// (using --pubsub-topic and --relay=false)
// This will have to be removed or changed with community sharding will be
// implemented.
if w.opts.shards != nil {
err = w.SetRelayShards(*w.opts.shards)
if err != nil {
return err
}
}

Expand Down

0 comments on commit 474fe3f

Please sign in to comment.