feat: add gossipsub peer exchange option to wakuV2

This commit is contained in:
Richard Ramos 2021-09-28 10:03:32 -04:00
parent bbafc704b1
commit 524e864398
4 changed files with 15 additions and 1 deletions

View File

@ -254,6 +254,7 @@ func (b *StatusNode) wakuV2Service(nodeKey string, wakuCfg *params.WakuV2Config,
StoreNodes: clusterCfg.StoreNodes,
FilterNodes: clusterCfg.FilterNodes,
LightpushNodes: clusterCfg.LightpushNodes,
PeerExchange: clusterCfg.PeerExchange,
}
if cfg.Host == "" {

View File

@ -288,6 +288,9 @@ type ClusterConfig struct {
// LightpushNodes is a list of wakuv2 lightpush nodes (libp2p)
LightpushNodes []string
// PeerExchange determines whether GossipSub Peer Exchange is enabled or not
PeerExchange bool
}
// String dumps config object as nicely indented JSON

View File

@ -28,6 +28,7 @@ type Config struct {
SoftBlacklistedPeerIDs []string `toml:",omitempty"`
Host string `toml:",omitempty"`
Port int `toml:",omitempty"`
PeerExchange bool `toml:",omitempty"`
KeepAliveInterval int `toml:",omitempty"`
LightClient bool `toml:",omitempty"`
RelayNodes []string `toml:",omitempty"`

View File

@ -179,7 +179,16 @@ func New(nodeKey string, cfg *Config, logger *zap.Logger) (*Waku, error) {
opts = append(opts, node.WithLightPush())
opts = append(opts, node.WithWakuFilter())
} else {
opts = append(opts, node.WithWakuRelay(wakurelay.WithMaxMessageSize(int(waku.settings.MaxMsgSize))))
relayOpts := []wakurelay.Option{
wakurelay.WithMaxMessageSize(int(waku.settings.MaxMsgSize)),
wakurelay.WithPeerExchange(cfg.PeerExchange),
}
if cfg.PeerExchange {
relayOpts = append(relayOpts, wakurelay.WithPeerExchange(true))
}
opts = append(opts, node.WithWakuRelay(relayOpts...))
}
if waku.node, err = node.New(context.Background(), opts...); err != nil {