mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-14 23:06:04 +01:00
graph/db: add StoreOptions to NewSQLStore
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package graphdb
|
package graphdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/sqldb"
|
"github.com/lightningnetwork/lnd/sqldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,9 +39,21 @@ var _ V1Store = (*SQLStore)(nil)
|
|||||||
|
|
||||||
// NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries
|
// NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries
|
||||||
// storage backend.
|
// storage backend.
|
||||||
func NewSQLStore(db BatchedSQLQueries, kvStore *KVStore) *SQLStore {
|
func NewSQLStore(db BatchedSQLQueries, kvStore *KVStore,
|
||||||
|
options ...StoreOptionModifier) (*SQLStore, error) {
|
||||||
|
|
||||||
|
opts := DefaultOptions()
|
||||||
|
for _, o := range options {
|
||||||
|
o(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.NoMigration {
|
||||||
|
return nil, fmt.Errorf("the NoMigration option is not yet " +
|
||||||
|
"supported for SQL stores")
|
||||||
|
}
|
||||||
|
|
||||||
return &SQLStore{
|
return &SQLStore{
|
||||||
db: db,
|
db: db,
|
||||||
KVStore: kvStore,
|
KVStore: kvStore,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,5 +38,8 @@ func NewTestDB(t testing.TB) V1Store {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return NewSQLStore(executor, graphStore)
|
store, err := NewSQLStore(executor, graphStore)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return store
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,5 +31,8 @@ func NewTestDB(t testing.TB) V1Store {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return NewSQLStore(executor, graphStore)
|
store, err := NewSQLStore(executor, graphStore)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
return store
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user