mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-29 14:23:09 +02:00
In this commit, a new `test_native_sql` build flag is defined. If this build flag is used along with the `--use-native-sql` config option, then the SQLStore implementation of the graphdb.V1Store will be initialised. This is then used to run our itest suite against the new SQLStore graph implementation. NOTE that this only works for new nodes currently - the migration from kv-to-sql is yet to be implemeneted.
32 lines
721 B
Go
32 lines
721 B
Go
//go:build test_native_sql
|
|
|
|
package lnd
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
|
"github.com/lightningnetwork/lnd/kvdb"
|
|
"github.com/lightningnetwork/lnd/sqldb"
|
|
)
|
|
|
|
// getGraphStore returns a graphdb.V1Store backed by a graphdb.SQLStore
|
|
// implementation.
|
|
func (d *DefaultDatabaseBuilder) getGraphStore(baseDB *sqldb.BaseDB,
|
|
_ kvdb.Backend, opts ...graphdb.StoreOptionModifier) (graphdb.V1Store,
|
|
error) {
|
|
|
|
graphExecutor := sqldb.NewTransactionExecutor(
|
|
baseDB, func(tx *sql.Tx) graphdb.SQLQueries {
|
|
return baseDB.WithTx(tx)
|
|
},
|
|
)
|
|
|
|
return graphdb.NewSQLStore(
|
|
&graphdb.SQLStoreConfig{
|
|
ChainHash: *d.cfg.ActiveNetParams.GenesisHash,
|
|
},
|
|
graphExecutor, opts...,
|
|
)
|
|
}
|