mirror of https://github.com/status-im/go-waku.git
fix: setup shards (#1256)
This commit is contained in:
parent
dd82c24e00
commit
96702e278b
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -464,15 +464,19 @@ 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.
|
||||
}
|
||||
|
||||
//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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if w.opts.keepAliveRandomPeersInterval > time.Duration(0) || w.opts.keepAliveAllPeersInterval > time.Duration(0) {
|
||||
w.wg.Add(1)
|
||||
|
|
Loading…
Reference in New Issue