address review feedback
This commit is contained in:
parent
3de945feaf
commit
881da9e654
|
@ -318,14 +318,12 @@ func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServe
|
|||
KeepAliveInterval: nodeConfig.WakuV2Config.KeepAliveInterval,
|
||||
Rendezvous: nodeConfig.Rendezvous,
|
||||
WakuNodes: nodeConfig.ClusterConfig.WakuNodes,
|
||||
EnablePeerExchangeServer: nodeConfig.WakuV2Config.PeerExchange,
|
||||
EnableStore: nodeConfig.WakuV2Config.EnableStore,
|
||||
StoreCapacity: nodeConfig.WakuV2Config.StoreCapacity,
|
||||
StoreSeconds: nodeConfig.WakuV2Config.StoreSeconds,
|
||||
DiscoveryLimit: nodeConfig.WakuV2Config.DiscoveryLimit,
|
||||
DiscV5BootstrapNodes: nodeConfig.ClusterConfig.DiscV5BootstrapNodes,
|
||||
Nameserver: nodeConfig.WakuV2Config.Nameserver,
|
||||
EnableDiscV5: nodeConfig.WakuV2Config.EnableDiscV5,
|
||||
UDPPort: nodeConfig.WakuV2Config.UDPPort,
|
||||
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
|
||||
DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(),
|
||||
|
@ -334,13 +332,15 @@ func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServe
|
|||
ClusterID: nodeConfig.ClusterConfig.ClusterID,
|
||||
}
|
||||
|
||||
// apply peer exchange settings
|
||||
// Configure peer exchange and discv5 settings based on node type
|
||||
if cfg.LightClient {
|
||||
cfg.EnablePeerExchangeServer = false
|
||||
cfg.EnablePeerExchangeClient = true
|
||||
cfg.EnableDiscV5 = false
|
||||
} else {
|
||||
cfg.EnablePeerExchangeServer = true
|
||||
cfg.EnablePeerExchangeClient = false
|
||||
cfg.EnableDiscV5 = true
|
||||
}
|
||||
|
||||
if nodeConfig.WakuV2Config.MaxMessageSize > 0 {
|
||||
|
|
|
@ -196,6 +196,7 @@ type WakuV2Config struct {
|
|||
Nameserver string
|
||||
|
||||
// EnableDiscV5 indicates if DiscoveryV5 is enabled or not
|
||||
// Deprecated: will be calculated based on LightClient
|
||||
EnableDiscV5 bool
|
||||
|
||||
// UDPPort number to start discovery v5
|
||||
|
|
|
@ -21,6 +21,8 @@ package wakuv2
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
||||
|
||||
"github.com/status-im/status-go/protocol/common/shard"
|
||||
|
@ -30,6 +32,11 @@ import (
|
|||
"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.
|
||||
type Config struct {
|
||||
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
|
||||
}
|
||||
|
||||
func (c *Config) Validate() error {
|
||||
func (c *Config) Validate(logger *zap.Logger) error {
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
|
|
@ -170,8 +170,8 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
|||
}
|
||||
|
||||
cfg = setDefaults(cfg)
|
||||
if err = cfg.Validate(); err != nil {
|
||||
logger.Warn("bad wakuv2 configuration", zap.Error(err))
|
||||
if err = cfg.Validate(logger); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Info("starting wakuv2 with config", zap.Any("config", cfg))
|
||||
|
|
Loading…
Reference in New Issue