address review feedback
This commit is contained in:
parent
3de945feaf
commit
881da9e654
|
@ -311,36 +311,36 @@ func (b *StatusNode) wakuService(wakuCfg *params.WakuConfig, clusterCfg *params.
|
||||||
func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServerURL string) (*wakuv2.Waku, error) {
|
func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServerURL string) (*wakuv2.Waku, error) {
|
||||||
if b.wakuV2Srvc == nil {
|
if b.wakuV2Srvc == nil {
|
||||||
cfg := &wakuv2.Config{
|
cfg := &wakuv2.Config{
|
||||||
MaxMessageSize: wakucommon.DefaultMaxMessageSize,
|
MaxMessageSize: wakucommon.DefaultMaxMessageSize,
|
||||||
Host: nodeConfig.WakuV2Config.Host,
|
Host: nodeConfig.WakuV2Config.Host,
|
||||||
Port: nodeConfig.WakuV2Config.Port,
|
Port: nodeConfig.WakuV2Config.Port,
|
||||||
LightClient: nodeConfig.WakuV2Config.LightClient,
|
LightClient: nodeConfig.WakuV2Config.LightClient,
|
||||||
KeepAliveInterval: nodeConfig.WakuV2Config.KeepAliveInterval,
|
KeepAliveInterval: nodeConfig.WakuV2Config.KeepAliveInterval,
|
||||||
Rendezvous: nodeConfig.Rendezvous,
|
Rendezvous: nodeConfig.Rendezvous,
|
||||||
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
|
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
|
||||||
EnablePeerExchangeServer: nodeConfig.WakuV2Config.PeerExchange,
|
EnableStore: nodeConfig.WakuV2Config.EnableStore,
|
||||||
EnableStore: nodeConfig.WakuV2Config.EnableStore,
|
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
|
||||||
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
|
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
|
||||||
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
|
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
|
||||||
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
|
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
|
||||||
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
|
Nameserver: nodeConfig.WakuV2Config.Nameserver,
|
||||||
Nameserver: nodeConfig.WakuV2Config.Nameserver,
|
UDPPort: nodeConfig.WakuV2Config.UDPPort,
|
||||||
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
|
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
|
||||||
UDPPort: nodeConfig.WakuV2Config.UDPPort,
|
DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(),
|
||||||
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
|
UseShardAsDefaultTopic: nodeConfig.WakuV2Config.UseShardAsDefaultTopic,
|
||||||
DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(),
|
TelemetryServerURL: telemetryServerURL,
|
||||||
UseShardAsDefaultTopic: nodeConfig.WakuV2Config.UseShardAsDefaultTopic,
|
ClusterID: nodeConfig.ClusterConfig.ClusterID,
|
||||||
TelemetryServerURL: telemetryServerURL,
|
|
||||||
ClusterID: nodeConfig.ClusterConfig.ClusterID,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply peer exchange settings
|
// Configure peer exchange and discv5 settings based on node type
|
||||||
if cfg.LightClient {
|
if cfg.LightClient {
|
||||||
cfg.EnablePeerExchangeServer = false
|
cfg.EnablePeerExchangeServer = false
|
||||||
cfg.EnablePeerExchangeClient = true
|
cfg.EnablePeerExchangeClient = true
|
||||||
|
cfg.EnableDiscV5 = false
|
||||||
} else {
|
} else {
|
||||||
cfg.EnablePeerExchangeServer = true
|
cfg.EnablePeerExchangeServer = true
|
||||||
cfg.EnablePeerExchangeClient = false
|
cfg.EnablePeerExchangeClient = false
|
||||||
|
cfg.EnableDiscV5 = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if nodeConfig.WakuV2Config.MaxMessageSize > 0 {
|
if nodeConfig.WakuV2Config.MaxMessageSize > 0 {
|
||||||
|
|
|
@ -196,6 +196,7 @@ type WakuV2Config struct {
|
||||||
Nameserver string
|
Nameserver string
|
||||||
|
|
||||||
// EnableDiscV5 indicates if DiscoveryV5 is enabled or not
|
// EnableDiscV5 indicates if DiscoveryV5 is enabled or not
|
||||||
|
// Deprecated: will be calculated based on LightClient
|
||||||
EnableDiscV5 bool
|
EnableDiscV5 bool
|
||||||
|
|
||||||
// UDPPort number to start discovery v5
|
// UDPPort number to start discovery v5
|
||||||
|
|
|
@ -21,6 +21,8 @@ package wakuv2
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
|
|
||||||
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
||||||
|
|
||||||
"github.com/status-im/status-go/protocol/common/shard"
|
"github.com/status-im/status-go/protocol/common/shard"
|
||||||
|
@ -30,6 +32,11 @@ import (
|
||||||
"github.com/status-im/status-go/wakuv2/common"
|
"github.com/status-im/status-go/wakuv2/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrBadLightClientConfig = errors.New("either peer exchange server or discv5 must be disabled, and the peer exchange client must be enabled")
|
||||||
|
ErrBadFullNodeConfig = errors.New("peer exchange server and discv5 must be enabled, and the peer exchange client must be disabled")
|
||||||
|
)
|
||||||
|
|
||||||
// Config represents the configuration state of a waku node.
|
// Config represents the configuration state of a waku node.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MaxMessageSize uint32 `toml:",omitempty"` // Maximal message length allowed by the waku node
|
MaxMessageSize uint32 `toml:",omitempty"` // Maximal message length allowed by the waku node
|
||||||
|
@ -61,12 +68,14 @@ type Config struct {
|
||||||
SkipPublishToTopic bool `toml:",omitempty"` // Used in testing
|
SkipPublishToTopic bool `toml:",omitempty"` // Used in testing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) Validate() error {
|
func (c *Config) Validate(logger *zap.Logger) error {
|
||||||
if c.LightClient && (c.EnablePeerExchangeServer || c.EnableDiscV5 || !c.EnablePeerExchangeClient) {
|
if c.LightClient && (c.EnablePeerExchangeServer || c.EnableDiscV5 || !c.EnablePeerExchangeClient) {
|
||||||
return errors.New("bad configuration for a light client: either peer exchange server or discv5 must be disabled, and the peer exchange client must be enabled")
|
logger.Warn("bad configuration for a light client", zap.Error(ErrBadLightClientConfig))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
if !c.LightClient && (!c.EnablePeerExchangeServer || !c.EnableDiscV5 || c.EnablePeerExchangeClient) {
|
if !c.LightClient && (!c.EnablePeerExchangeServer || !c.EnableDiscV5 || c.EnablePeerExchangeClient) {
|
||||||
return errors.New("bad configuration for a full node: peer exchange server and discv5 must be enabled, and the peer exchange client must be disabled")
|
logger.Warn("bad configuration for a full node", zap.Error(ErrBadFullNodeConfig))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,8 +170,8 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = setDefaults(cfg)
|
cfg = setDefaults(cfg)
|
||||||
if err = cfg.Validate(); err != nil {
|
if err = cfg.Validate(logger); err != nil {
|
||||||
logger.Warn("bad wakuv2 configuration", zap.Error(err))
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("starting wakuv2 with config", zap.Any("config", cfg))
|
logger.Info("starting wakuv2 with config", zap.Any("config", cfg))
|
||||||
|
|
Loading…
Reference in New Issue