chore: update flags

This commit is contained in:
Richard Ramos 2023-04-13 15:28:46 -04:00 committed by RichΛrd
parent 0b01e4bb16
commit c559932931
4 changed files with 28 additions and 61 deletions

View File

@ -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,

View File

@ -53,14 +53,11 @@ func main() {
StoreMessageRetentionTime,
StoreMessageRetentionCapacity,
StoreResumePeer,
SwapFlag,
SwapMode,
SwapPaymentThreshold,
SwapDisconnectThreshold,
FilterFlag,
FilterV2Flag,
FilterLegacyFlag,
LightClient,
FilterNode,
FilterLegacyNode,
FilterTimeout,
LightPush,
LightPushNode,

View File

@ -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 {

View File

@ -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