fix: disable discv5 in lightmode and enable peer-exchange in lightmode

This commit is contained in:
Prem Chaitanya Prathi 2024-02-13 07:20:00 +05:30 committed by frank
parent 637ce1d5eb
commit cbec0dc726
1 changed files with 12 additions and 3 deletions

View File

@ -218,17 +218,26 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
onHistoricMessagesRequestFailed: onHistoricMessagesRequestFailed, onHistoricMessagesRequestFailed: onHistoricMessagesRequestFailed,
onPeerStats: onPeerStats, onPeerStats: onPeerStats,
} }
enablePeerExchange := cfg.PeerExchange
enabledDiscv5 := cfg.EnableDiscV5
if cfg.LightClient {
enablePeerExchange = true
enabledDiscv5 = false
} else {
enablePeerExchange = false
enabledDiscv5 = true
}
waku.settings = settings{ waku.settings = settings{
MaxMsgSize: cfg.MaxMessageSize, MaxMsgSize: cfg.MaxMessageSize,
LightClient: cfg.LightClient, LightClient: cfg.LightClient,
MinPeersForRelay: cfg.MinPeersForRelay, MinPeersForRelay: cfg.MinPeersForRelay,
MinPeersForFilter: cfg.MinPeersForFilter, MinPeersForFilter: cfg.MinPeersForFilter,
PeerExchange: cfg.PeerExchange, PeerExchange: enablePeerExchange,
DiscoveryLimit: cfg.DiscoveryLimit, DiscoveryLimit: cfg.DiscoveryLimit,
Nameserver: cfg.Nameserver, Nameserver: cfg.Nameserver,
Resolver: cfg.Resolver, Resolver: cfg.Resolver,
EnableDiscV5: cfg.EnableDiscV5, EnableDiscV5: enabledDiscv5,
} }
waku.settings.DefaultPubsubTopic = cfg.DefaultShardPubsubTopic waku.settings.DefaultPubsubTopic = cfg.DefaultShardPubsubTopic
@ -273,7 +282,7 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
node.WithMaxMsgSize(1024 * 1024), node.WithMaxMsgSize(1024 * 1024),
} }
if cfg.EnableDiscV5 && !waku.settings.LightClient { if enabledDiscv5 {
bootnodes, err := waku.getDiscV5BootstrapNodes(waku.ctx, cfg.DiscV5BootstrapNodes) bootnodes, err := waku.getDiscV5BootstrapNodes(waku.ctx, cfg.DiscV5BootstrapNodes)
if err != nil { if err != nil {
logger.Error("failed to get bootstrap nodes", zap.Error(err)) logger.Error("failed to get bootstrap nodes", zap.Error(err))