diff --git a/cmd/waku/flags.go b/cmd/waku/flags.go index d8c714df..7fc8daf3 100644 --- a/cmd/waku/flags.go +++ b/cmd/waku/flags.go @@ -263,49 +263,21 @@ var ( }, EnvVars: []string{"WAKUNODE2_STORE_RESUME_PEER"}, }) - SwapFlag = altsrc.NewBoolFlag(&cli.BoolFlag{ - Name: "swap", - Usage: "Enable swap protocol", - Value: false, - Destination: &options.Swap.Enable, - EnvVars: []string{"WAKUNODE2_SWAP"}, - }) - SwapMode = altsrc.NewIntFlag(&cli.IntFlag{ - Name: "swap-mode", - Value: 0, - Usage: "Swap mode: 0=soft, 1=mock, 2=hard", - Destination: &options.Swap.Mode, - EnvVars: []string{"WAKUNODE2_SWAP_MODE"}, - }) - SwapPaymentThreshold = altsrc.NewIntFlag(&cli.IntFlag{ - Name: "swap-payment-threshold", - Value: 100, - Usage: "Threshold for payment", - Destination: &options.Swap.PaymentThreshold, - EnvVars: []string{"WAKUNODE2_SWAP_PAYMENT_THRESHOLD"}, - }) - SwapDisconnectThreshold = altsrc.NewIntFlag(&cli.IntFlag{ - Name: "swap-disconnect-threshold", - Value: -100, - Usage: "Threshold for disconnecting", - Destination: &options.Swap.DisconnectThreshold, - EnvVars: []string{"WAKUNODE2_SWAP_DISCONNECT_THRESHOLD"}, - }) FilterFlag = altsrc.NewBoolFlag(&cli.BoolFlag{ Name: "filter", Usage: "Enable filter protocol", Destination: &options.Filter.Enable, EnvVars: []string{"WAKUNODE2_FILTER"}, }) - FilterV2Flag = altsrc.NewBoolFlag(&cli.BoolFlag{ - Name: "use-filterv2", - Usage: "Use filterV2 protocol (experimental)", - Destination: &options.Filter.UseV2, - EnvVars: []string{"WAKUNODE2_FILTERV2"}, + FilterLegacyFlag = altsrc.NewBoolFlag(&cli.BoolFlag{ + Name: "use-filter-legacy", + Usage: "Use filter protocol (legacy)", + Destination: &options.Filter.UseV1, + EnvVars: []string{"WAKUNODE2_USE_FILTER_LEGACY"}, }) LightClient = altsrc.NewBoolFlag(&cli.BoolFlag{ Name: "light-client", - Usage: "Don't accept filter subscribers", + Usage: "Don't accept filter subscribers (only for filter-legacy)", Destination: &options.Filter.DisableFullNode, EnvVars: []string{"WAKUNODE2_LIGHT_CLIENT"}, }) @@ -317,6 +289,14 @@ var ( }, EnvVars: []string{"WAKUNODE2_FILTERNODE"}, }) + FilterLegacyNode = cliutils.NewGenericFlagMultiValue(&cli.GenericFlag{ + Name: "legacy-filternode", + Usage: "Multiaddr of a peer that supports legacy filter protocol. Option may be repeated", + Value: &cliutils.MultiaddrSlice{ + Values: &options.Filter.NodesV1, + }, + EnvVars: []string{"WAKUNODE2_LEGACY_FILTERNODE"}, + }) FilterTimeout = altsrc.NewDurationFlag(&cli.DurationFlag{ Name: "filter-timeout", Value: 14400 * time.Second, diff --git a/cmd/waku/main.go b/cmd/waku/main.go index e728cbeb..389b4e70 100644 --- a/cmd/waku/main.go +++ b/cmd/waku/main.go @@ -53,14 +53,11 @@ func main() { StoreMessageRetentionTime, StoreMessageRetentionCapacity, StoreResumePeer, - SwapFlag, - SwapMode, - SwapPaymentThreshold, - SwapDisconnectThreshold, FilterFlag, - FilterV2Flag, + FilterLegacyFlag, LightClient, FilterNode, + FilterLegacyNode, FilterTimeout, LightPush, LightPushNode, diff --git a/waku/node.go b/waku/node.go index e4213f91..18b44c11 100644 --- a/waku/node.go +++ b/waku/node.go @@ -163,15 +163,14 @@ func Execute(options Options) { nodeOpts = append(nodeOpts, node.WithWakuRelayAndMinPeers(options.Relay.MinRelayPeersToPublish, wakurelayopts...)) } + nodeOpts = append(nodeOpts, node.WithWakuFilterLightNode()) + if options.Filter.Enable { - if options.Filter.UseV2 { - nodeOpts = append(nodeOpts, node.WithWakuFilterLightNode()) - if !options.Filter.DisableFullNode { - nodeOpts = append(nodeOpts, node.WithWakuFilterFullNode(filter.WithTimeout(options.Filter.Timeout))) - } - } else { - nodeOpts = append(nodeOpts, node.WithLegacyWakuFilter(!options.Filter.DisableFullNode, legacy_filter.WithTimeout(options.Filter.Timeout))) - } + nodeOpts = append(nodeOpts, node.WithWakuFilterFullNode(filter.WithTimeout(options.Filter.Timeout))) + } + + if options.Filter.UseV1 { + nodeOpts = append(nodeOpts, node.WithLegacyWakuFilter(!options.Filter.DisableFullNode, legacy_filter.WithTimeout(options.Filter.Timeout))) } var dbStore *persistence.DBStore @@ -259,11 +258,10 @@ func Execute(options Options) { addPeers(wakuNode, options.Store.Nodes, store.StoreID_v20beta4) addPeers(wakuNode, options.LightPush.Nodes, lightpush.LightPushID_v20beta1) addPeers(wakuNode, options.Rendezvous.Nodes, rendezvous.RendezvousID) + addPeers(wakuNode, options.Filter.Nodes, filter.FilterSubscribeID_v20beta1) - if options.Filter.UseV2 { - addPeers(wakuNode, options.Filter.Nodes, legacy_filter.FilterID_v20beta1) - } else { - addPeers(wakuNode, options.Filter.Nodes, legacy_filter.FilterID_v20beta1) + if options.Filter.UseV1 { + addPeers(wakuNode, options.Filter.NodesV1, legacy_filter.FilterID_v20beta1) } if err = wakuNode.Start(ctx); err != nil { diff --git a/waku/options.go b/waku/options.go index d401ad5c..d9d51c2e 100644 --- a/waku/options.go +++ b/waku/options.go @@ -47,9 +47,10 @@ type RLNRelayOptions struct { // restricted devices. type FilterOptions struct { Enable bool - UseV2 bool + UseV1 bool DisableFullNode bool Nodes []multiaddr.Multiaddr + NodesV1 []multiaddr.Multiaddr Timeout time.Duration } @@ -76,14 +77,6 @@ type StoreOptions struct { Nodes []multiaddr.Multiaddr } -// SwapOptions are settings used for configuring the swap protocol -type SwapOptions struct { - Enable bool - Mode int - PaymentThreshold int - DisconnectThreshold int -} - // DNSDiscoveryOptions are settings used for enabling DNS-based discovery // protocol that stores merkle trees in DNS records which contain connection // information for nodes. It's very useful for bootstrapping a p2p network. @@ -172,7 +165,6 @@ type Options struct { Websocket WSOptions Relay RelayOptions Store StoreOptions - Swap SwapOptions Filter FilterOptions LightPush LightpushOptions RLNRelay RLNRelayOptions