graph/db: rename V1Store to Store

The underling store will store gossip messages across gossip versions
and we will instead expose version parameters on many of the methods. So
this interface really just abstracts the underlying store/schema type.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:20 +02:00
1 parent cb2fc6621e
commit bc76383e15
11 files changed
+111 -111

No files matched your search

+26 -26
View File
@@ -72,19 +72,19 @@ var (
// and a function to open the connection.
type dbConnection struct {
name string
open func(testing.TB) V1Store
open func(testing.TB) Store
}
// This var block defines the various database connections that we will use
// for testing. Each connection is defined as a dbConnection struct that
// contains a name and an open function. The open function is used to create
// a new V1Store instance for the given database type.
// a new Store instance for the given database type.
var (
// kvdbBBoltConn is a connection to a kvdb-bbolt database called
// channel.db.
kvdbBBoltConn = dbConnection{
name: "kvdb-bbolt",
open: func(b testing.TB) V1Store {
open: func(b testing.TB) Store {
return connectBBoltDB(b, bboltDBPath, kvdbBBoltFile)
},
}
@@ -93,7 +93,7 @@ var (
// channel.sqlite.
kvdbSqliteConn = dbConnection{
name: "kvdb-sqlite",
open: func(b testing.TB) V1Store {
open: func(b testing.TB) Store {
return connectKVDBSqlite(
b, kvdbSqlitePath, kvdbSqliteFile,
)
@@ -104,7 +104,7 @@ var (
// called lnd.sqlite.
nativeSQLSqliteConn = dbConnection{
name: "native-sqlite",
open: func(b testing.TB) V1Store {
open: func(b testing.TB) Store {
return connectNativeSQLite(
b, sqldb.DefaultSQLiteConfig(),
nativeSQLSqlitePath, nativeSQLSqliteFile,
@@ -116,7 +116,7 @@ var (
// using a postgres connection string.
kvdbPostgresConn = dbConnection{
name: "kvdb-postgres",
open: func(b testing.TB) V1Store {
open: func(b testing.TB) Store {
return connectKVDBPostgres(b, kvdbPostgresDNS)
},
}
@@ -125,7 +125,7 @@ var (
// database using a postgres connection string.
nativeSQLPostgresConn = dbConnection{
name: "native-postgres",
open: func(b testing.TB) V1Store {
open: func(b testing.TB) Store {
return connectNativePostgres(
b, sqldb.DefaultPostgresConfig(),
nativeSQLPostgresDNS,
@@ -134,10 +134,10 @@ var (
}
)
// connectNativePostgres creates a V1Store instance backed by a native Postgres
// connectNativePostgres creates a Store instance backed by a native Postgres
// database for testing purposes.
func connectNativePostgres(t testing.TB, cfg *sqldb.QueryConfig,
dsn string) V1Store {
dsn string) Store {
return newSQLStore(t, cfg, sqlPostgres(t, dsn))
}
@@ -157,10 +157,10 @@ func sqlPostgres(t testing.TB, dsn string) BatchedSQLQueries {
return newSQLExecutor(t, store)
}
// connectNativeSQLite creates a V1Store instance backed by a native SQLite
// connectNativeSQLite creates a Store instance backed by a native SQLite
// database for testing purposes.
func connectNativeSQLite(t testing.TB, cfg *sqldb.QueryConfig, dbPath,
file string) V1Store {
file string) Store {
return newSQLStore(t, cfg, sqlSQLite(t, dbPath, file))
}
@@ -205,9 +205,9 @@ func kvdbPostgres(t testing.TB, dsn string) kvdb.Backend {
return kvStore
}
// connectKVDBPostgres creates a V1Store instance backed by a kvdb-postgres
// connectKVDBPostgres creates a Store instance backed by a kvdb-postgres
// database for testing purposes.
func connectKVDBPostgres(t testing.TB, dsn string) V1Store {
func connectKVDBPostgres(t testing.TB, dsn string) Store {
return newKVStore(t, kvdbPostgres(t, dsn))
}
@@ -231,14 +231,14 @@ func kvdbSqlite(t testing.TB, dbPath, fileName string) kvdb.Backend {
return kvStore
}
// connectKVDBSqlite creates a V1Store instance backed by a kvdb-sqlite
// connectKVDBSqlite creates a Store instance backed by a kvdb-sqlite
// database for testing purposes.
func connectKVDBSqlite(t testing.TB, dbPath, fileName string) V1Store {
func connectKVDBSqlite(t testing.TB, dbPath, fileName string) Store {
return newKVStore(t, kvdbSqlite(t, dbPath, fileName))
}
// connectBBoltDB creates a new BBolt database connection for testing.
func connectBBoltDB(t testing.TB, dbPath, fileName string) V1Store {
func connectBBoltDB(t testing.TB, dbPath, fileName string) Store {
return newKVStore(t, kvdbBBolt(t, dbPath, fileName))
}
@@ -261,7 +261,7 @@ func kvdbBBolt(t testing.TB, dbPath, fileName string) kvdb.Backend {
// newKVStore creates a new KVStore instance for testing using a provided
// kvdb.Backend instance.
func newKVStore(t testing.TB, backend kvdb.Backend) V1Store {
func newKVStore(t testing.TB, backend kvdb.Backend) Store {
store, err := NewKVStore(backend, testStoreOptions...)
require.NoError(t, err)
@@ -286,7 +286,7 @@ func newSQLExecutor(t testing.TB, db sqldb.DB) BatchedSQLQueries {
// newSQLStore creates a new SQLStore instance for testing using a provided
// sqldb.DB instance.
func newSQLStore(t testing.TB, cfg *sqldb.QueryConfig,
db BatchedSQLQueries) V1Store {
db BatchedSQLQueries) Store {
store, err := NewSQLStore(
&SQLStoreConfig{
@@ -587,7 +587,7 @@ func BenchmarkCacheLoading(b *testing.B) {
}
}
// BenchmarkGraphReadMethods benchmarks various read calls of various V1Store
// BenchmarkGraphReadMethods benchmarks various read calls of various Store
// implementations.
//
// NOTE: this is to be run against a local graph database. It can be run
@@ -614,11 +614,11 @@ func BenchmarkGraphReadMethods(b *testing.B) {
tests := []struct {
name string
fn func(b testing.TB, store V1Store)
fn func(b testing.TB, store Store)
}{
{
name: "ForEachNode",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
err := store.ForEachNode(
ctx,
func(_ *models.Node) error {
@@ -635,7 +635,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
},
{
name: "ForEachChannel",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
//nolint:ll
err := store.ForEachChannel(
ctx, func(_ *models.ChannelEdgeInfo,
@@ -655,7 +655,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
},
{
name: "NodeUpdatesInHorizon",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
iter := store.NodeUpdatesInHorizon(
time.Unix(0, 0), time.Now(),
)
@@ -665,7 +665,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
},
{
name: "ForEachNodeCacheable",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
err := store.ForEachNodeCacheable(
ctx, func(_ route.Vertex,
_ *lnwire.FeatureVector) error {
@@ -683,7 +683,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
},
{
name: "ForEachNodeCached",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
//nolint:ll
err := store.ForEachNodeCached(
ctx, false, func(context.Context,
@@ -704,7 +704,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
},
{
name: "ChanUpdatesInHorizon",
fn: func(b testing.TB, store V1Store) {
fn: func(b testing.TB, store Store) {
iter := store.ChanUpdatesInHorizon(
time.Unix(0, 0), time.Now(),
)