Use function to calculate duration in days

This commit is contained in:
Richard Ramos 2021-11-06 09:20:22 -04:00
parent f561e217aa
commit 08c5c2303e
2 changed files with 8 additions and 3 deletions

View File

@ -144,10 +144,9 @@ func Execute(options Options) {
} }
if options.Store.Enable { if options.Store.Enable {
maxDays := time.Hour * 24 * time.Duration(options.Store.RetentionMaxDays) nodeOpts = append(nodeOpts, node.WithWakuStoreAndLimits(options.Store.ShouldResume, options.Store.RetentionMaxDaysDuration(), options.Store.RetentionMaxMessages))
nodeOpts = append(nodeOpts, node.WithWakuStoreAndLimits(options.Store.ShouldResume, maxDays, options.Store.RetentionMaxMessages))
if options.UseDB { 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") failOnErr(err, "DBStore")
nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore)) nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore))
} else { } else {

View File

@ -1,5 +1,7 @@
package waku package waku
import "time"
type RendezvousOptions struct { type RendezvousOptions struct {
Enable bool `long:"rendezvous" description:"Enable rendezvous protocol for peer discovery"` 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"` 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"` 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 // DNSDiscoveryOptions are settings used for enabling DNS-based discovery
// protocol that stores merkle trees in DNS records which contain connection // protocol that stores merkle trees in DNS records which contain connection
// information for nodes. It's very useful for bootstrapping a p2p network. // information for nodes. It's very useful for bootstrapping a p2p network.