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)
|
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
|
//Process pubSub and contentTopics specified and arrive at all corresponding pubSubTopics
|
||||||
pubSubTopicMap, err := processTopics(options)
|
pubSubTopicMap, err := processTopics(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -325,6 +320,22 @@ func Execute(options NodeOptions) error {
|
||||||
pubSubTopicMapKeys = append(pubSubTopicMapKeys, k)
|
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 {
|
if err = wakuNode.Start(ctx); err != nil {
|
||||||
return nonRecoverError(err)
|
return nonRecoverError(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,13 +464,17 @@ func (w *WakuNode) Start(ctx context.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
//TODO: setting this up temporarily to improve connectivity success for lightNode
|
||||||
err = w.SetRelayShards(*w.opts.shards)
|
// in status. Also, when executing go-waku service-node as a lightclient
|
||||||
if err != nil {
|
// (using --pubsub-topic and --relay=false)
|
||||||
return err
|
// 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue