diff --git a/waku/node.go b/waku/node.go index f5cee94d..a688ab1b 100644 --- a/waku/node.go +++ b/waku/node.go @@ -144,10 +144,9 @@ func Execute(options Options) { } if options.Store.Enable { - maxDays := time.Hour * 24 * time.Duration(options.Store.RetentionMaxDays) - nodeOpts = append(nodeOpts, node.WithWakuStoreAndLimits(options.Store.ShouldResume, maxDays, options.Store.RetentionMaxMessages)) + nodeOpts = append(nodeOpts, node.WithWakuStoreAndLimits(options.Store.ShouldResume, options.Store.RetentionMaxDaysDuration(), options.Store.RetentionMaxMessages)) if options.UseDB { - dbStore, err := persistence.NewDBStore(persistence.WithDB(db), persistence.WithRetentionPolicy(options.Store.RetentionMaxMessages, maxDays)) + dbStore, err := persistence.NewDBStore(persistence.WithDB(db), persistence.WithRetentionPolicy(options.Store.RetentionMaxMessages, options.Store.RetentionMaxDaysDuration())) failOnErr(err, "DBStore") nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore)) } else { diff --git a/waku/options.go b/waku/options.go index 4672bb17..ae36d0f2 100644 --- a/waku/options.go +++ b/waku/options.go @@ -1,5 +1,7 @@ package waku +import "time" + type RendezvousOptions struct { Enable bool `long:"rendezvous" description:"Enable rendezvous protocol for peer discovery"` Nodes []string `long:"rendezvous-node" description:"Multiaddr of a waku2 rendezvous node. Option may be repeated"` @@ -43,6 +45,10 @@ type StoreOptions struct { Nodes []string `long:"store-node" description:"Multiaddr of a peer that supports store protocol. Option may be repeated"` } +func (s *StoreOptions) RetentionMaxDaysDuration() time.Duration { + return time.Duration(s.RetentionMaxDays) * time.Hour * 24 +} + // 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.