fix: enable store only when WithWakuStore is used

This commit is contained in:
Richard Ramos 2023-01-03 11:17:25 -04:00 committed by RichΛrd
parent 408b1de802
commit ea6d5bc7b8
9 changed files with 9 additions and 11 deletions

View File

@ -225,8 +225,8 @@ func Execute(options Options) {
nodeOpts = append(nodeOpts, node.WithWakuFilter(!options.Filter.DisableFullNode, filter.WithTimeout(options.Filter.Timeout)))
}
nodeOpts = append(nodeOpts, node.WithWakuStore(options.Store.Enable, options.Store.ResumeNodes...))
if options.Store.Enable {
nodeOpts = append(nodeOpts, node.WithWakuStore(options.Store.ResumeNodes...))
dbStore, err := persistence.NewDBStore(logger, persistence.WithDB(db), persistence.WithRetentionPolicy(options.Store.RetentionMaxMessages, options.Store.RetentionTime))
failOnErr(err, "DBStore")
nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore))

View File

@ -80,7 +80,7 @@ func TestConnectionStatusChanges(t *testing.T) {
node3, err := New(ctx,
WithHostAddress(hostAddr3),
WithWakuRelay(),
WithWakuStore(false),
WithWakuStore(),
WithMessageProvider(dbStore),
)
require.NoError(t, err)

View File

@ -341,7 +341,7 @@ func (w *WakuNode) Start() error {
}
// Subscribe store to topic
if w.opts.storeMsgs {
if w.opts.enableStore {
w.log.Info("Subscribing store to broadcaster")
w.bcaster.Register(nil, w.store.MessageChannel())
}

View File

@ -192,7 +192,7 @@ func TestDecoupledStoreFromRelay(t *testing.T) {
wakuNode2, err := New(ctx,
WithHostAddress(hostAddr2),
WithWakuFilter(false),
WithWakuStore(true),
WithWakuStore(),
WithMessageProvider(dbStore),
)
require.NoError(t, err)

View File

@ -67,7 +67,6 @@ type WakuNodeParameters struct {
enableStore bool
enableSwap bool
storeMsgs bool
resumeNodes []multiaddr.Multiaddr
messageProvider store.MessageProvider
@ -319,10 +318,9 @@ func WithWakuFilter(fullNode bool, filterOpts ...filter.Option) WakuNodeOption {
// WithWakuStore enables the Waku V2 Store protocol and if the messages should
// be stored or not in a message provider. If resumeNodes are specified, the
// store will attempt to resume message history using those nodes
func WithWakuStore(shouldStoreMessages bool, resumeNodes ...multiaddr.Multiaddr) WakuNodeOption {
func WithWakuStore(resumeNodes ...multiaddr.Multiaddr) WakuNodeOption {
return func(params *WakuNodeParameters) error {
params.enableStore = true
params.storeMsgs = shouldStoreMessages
params.resumeNodes = resumeNodes
return nil
}

View File

@ -42,7 +42,7 @@ func TestWakuOptions(t *testing.T) {
WithWakuRelay(),
WithWakuFilter(true),
WithDiscoveryV5(123, nil, false),
WithWakuStore(true),
WithWakuStore(),
WithMessageProvider(&persistence.DBStore{}),
WithLightPush(),
WithKeepAlive(time.Hour),

View File

@ -10,7 +10,7 @@ import (
)
func TestWakuRest(t *testing.T) {
options := node.WithWakuStore(false)
options := node.WithWakuStore()
n, err := node.New(context.Background(), options)
require.NoError(t, err)

View File

@ -10,7 +10,7 @@ import (
)
func makeStoreService(t *testing.T) *StoreService {
options := node.WithWakuStore(false)
options := node.WithWakuStore()
n, err := node.New(context.Background(), options)
require.NoError(t, err)
err = n.Start()

View File

@ -10,7 +10,7 @@ import (
)
func TestWakuRpc(t *testing.T) {
options := node.WithWakuStore(false)
options := node.WithWakuStore()
n, err := node.New(context.Background(), options)
require.NoError(t, err)