From 2fa30e87355acfe0a413a9d3b438c3b396fa591e Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 16 Jul 2025 08:33:02 +0200 Subject: [PATCH] graph+config: add sql pagination config to ChannelGraph --- config_test_native_sql.go | 3 ++- graph/db/sql_store.go | 3 +++ graph/db/test_postgres.go | 11 ++++++++--- graph/db/test_sqlite.go | 3 ++- itest/lnd_graph_migration_test.go | 3 ++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config_test_native_sql.go b/config_test_native_sql.go index ff1569aa0..b9b4debd0 100644 --- a/config_test_native_sql.go +++ b/config_test_native_sql.go @@ -32,7 +32,8 @@ func (d *DefaultDatabaseBuilder) getGraphStore(baseDB *sqldb.BaseDB, return graphdb.NewSQLStore( &graphdb.SQLStoreConfig{ - ChainHash: *d.cfg.ActiveNetParams.GenesisHash, + ChainHash: *d.cfg.ActiveNetParams.GenesisHash, + PaginationCfg: sqldb.DefaultPagedQueryConfig(), }, graphExecutor, opts..., ) diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index d9e6c650e..e61609733 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -182,6 +182,9 @@ type SQLStoreConfig struct { // ChainHash is the genesis hash for the chain that all the gossip // messages in this store are aimed at. ChainHash chainhash.Hash + + // PaginationCfg is the configuration for paginated queries. + PaginationCfg *sqldb.PagedQueryConfig } // NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries diff --git a/graph/db/test_postgres.go b/graph/db/test_postgres.go index 5e10d94cc..a812f998f 100644 --- a/graph/db/test_postgres.go +++ b/graph/db/test_postgres.go @@ -19,7 +19,9 @@ func NewTestDB(t testing.TB) V1Store { // NewTestDBFixture creates a new sqldb.TestPgFixture for testing purposes. func NewTestDBFixture(t *testing.T) *sqldb.TestPgFixture { - pgFixture := sqldb.NewTestPgFixture(t, sqldb.DefaultPostgresFixtureLifetime) + pgFixture := sqldb.NewTestPgFixture( + t, sqldb.DefaultPostgresFixtureLifetime, + ) t.Cleanup(func() { pgFixture.TearDown(t) }) @@ -28,7 +30,9 @@ func NewTestDBFixture(t *testing.T) *sqldb.TestPgFixture { // NewTestDBWithFixture is a helper function that creates a SQLStore backed by a // SQL database for testing. -func NewTestDBWithFixture(t testing.TB, pgFixture *sqldb.TestPgFixture) V1Store { +func NewTestDBWithFixture(t testing.TB, + pgFixture *sqldb.TestPgFixture) V1Store { + var querier BatchedSQLQueries if pgFixture == nil { querier = newBatchQuerier(t) @@ -38,7 +42,8 @@ func NewTestDBWithFixture(t testing.TB, pgFixture *sqldb.TestPgFixture) V1Store store, err := NewSQLStore( &SQLStoreConfig{ - ChainHash: *chaincfg.MainNetParams.GenesisHash, + ChainHash: *chaincfg.MainNetParams.GenesisHash, + PaginationCfg: sqldb.DefaultPagedQueryConfig(), }, querier, ) require.NoError(t, err) diff --git a/graph/db/test_sqlite.go b/graph/db/test_sqlite.go index 4d52b00ba..41773c66e 100644 --- a/graph/db/test_sqlite.go +++ b/graph/db/test_sqlite.go @@ -27,7 +27,8 @@ func NewTestDBFixture(_ *testing.T) *sqldb.TestPgFixture { func NewTestDBWithFixture(t testing.TB, _ *sqldb.TestPgFixture) V1Store { store, err := NewSQLStore( &SQLStoreConfig{ - ChainHash: *chaincfg.MainNetParams.GenesisHash, + ChainHash: *chaincfg.MainNetParams.GenesisHash, + PaginationCfg: sqldb.DefaultPagedQueryConfig(), }, newBatchQuerier(t), ) require.NoError(t, err) diff --git a/itest/lnd_graph_migration_test.go b/itest/lnd_graph_migration_test.go index d7417abe4..04745da49 100644 --- a/itest/lnd_graph_migration_test.go +++ b/itest/lnd_graph_migration_test.go @@ -144,7 +144,8 @@ func openNativeSQLGraphDB(ht *lntest.HarnessTest, store, err := graphdb.NewSQLStore( &graphdb.SQLStoreConfig{ - ChainHash: *ht.Miner().ActiveNet.GenesisHash, + ChainHash: *ht.Miner().ActiveNet.GenesisHash, + PaginationCfg: sqldb.DefaultPagedQueryConfig(), }, executor, )