lnd+paymentsdb: introduce harness for the payment sql backend
We prepare the code for the sql payment backend. However no payment db interface method for the sql backend is implemented yet. This will be done in the following commits. They currently use the embedded KVStore to satify the build environment.
This commit is contained in:
4 files changed
+145
-23
No files matched your search
@@ -4,8 +4,12 @@ package lnd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lncfg"
|
||||
paymentsdb "github.com/lightningnetwork/lnd/payments/db"
|
||||
"github.com/lightningnetwork/lnd/sqldb"
|
||||
"github.com/lightningnetwork/lnd/sqldb/sqlc"
|
||||
)
|
||||
|
||||
@@ -25,3 +29,28 @@ func (d *DefaultDatabaseBuilder) getSQLMigration(_ context.Context,
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
// getPaymentsStore returns a paymentsdb.DB backed by a paymentsdb.SQLStore
|
||||
// implementation.
|
||||
func (d *DefaultDatabaseBuilder) getPaymentsStore(baseDB *sqldb.BaseDB,
|
||||
kvBackend kvdb.Backend,
|
||||
opts ...paymentsdb.OptionModifier) (paymentsdb.DB, error) {
|
||||
|
||||
paymentsExecutor := sqldb.NewTransactionExecutor(
|
||||
baseDB, func(tx *sql.Tx) paymentsdb.SQLQueries {
|
||||
return baseDB.WithTx(tx)
|
||||
},
|
||||
)
|
||||
|
||||
queryConfig := d.cfg.DB.Sqlite.QueryConfig
|
||||
if d.cfg.DB.Backend == lncfg.PostgresBackend {
|
||||
queryConfig = d.cfg.DB.Postgres.QueryConfig
|
||||
}
|
||||
|
||||
return paymentsdb.NewSQLStore(
|
||||
&paymentsdb.SQLStoreConfig{
|
||||
QueryCfg: &queryConfig,
|
||||
},
|
||||
paymentsExecutor, opts...,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user