multi: separate Querier from BaseDB interfaces

A Querier holds the methods of sqlc.Querier interface relevant for a package.
BaseDB has Querier + ExecTx method.

This change is needed to simplify further rework of ExecTx.
pull/781/head
Boris Nagaev 3 months ago
parent 8d8cd9129f
commit 2847e83fcf
No known key found for this signature in database

@ -16,9 +16,9 @@ import (
"github.com/lightningnetwork/lnd/keychain"
)
// BaseDB is the interface that contains all the queries generated
// Querier is the interface that contains all the queries generated
// by sqlc for the reservation table.
type BaseDB interface {
type Querier interface {
// CreateReservation stores the reservation in the database.
CreateReservation(ctx context.Context,
arg sqlc.CreateReservationParams) error
@ -42,6 +42,12 @@ type BaseDB interface {
// UpdateReservation updates a reservation.
UpdateReservation(ctx context.Context,
arg sqlc.UpdateReservationParams) error
}
// BaseDB is the interface that contains all the queries generated
// by sqlc for the reservation table and transaction functionality.
type BaseDB interface {
Querier
// ExecTx allows for executing a function in the context of a database
// transaction.

@ -21,9 +21,9 @@ import (
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)
// InstantOutBaseDB is the interface that contains all the queries generated
// Querier is the interface that contains all the queries generated
// by sqlc for the instantout table.
type InstantOutBaseDB interface {
type Querier interface {
// InsertSwap inserts a new base swap.
InsertSwap(ctx context.Context, arg sqlc.InsertSwapParams) error
@ -53,6 +53,12 @@ type InstantOutBaseDB interface {
// GetInstantOutSwaps retrieves all instant out swaps.
GetInstantOutSwaps(ctx context.Context) ([]sqlc.GetInstantOutSwapsRow,
error)
}
// InstantOutBaseDB is the interface that contains all the queries generated
// by sqlc for the instantout table and transaction functionality.
type InstantOutBaseDB interface {
Querier
// ExecTx allows for executing a function in the context of a database
// transaction.

@ -15,7 +15,9 @@ import (
"github.com/lightningnetwork/lnd/lntypes"
)
type BaseDB interface {
// Querier is the interface that contains all the queries generated
// by sqlc for sweep batcher.
type Querier interface {
// ConfirmBatch confirms a batch by setting the state to confirmed.
ConfirmBatch(ctx context.Context, id int32) error
@ -52,6 +54,12 @@ type BaseDB interface {
// UpsertSweep inserts a sweep into the database, or updates an existing
// sweep if it already exists.
UpsertSweep(ctx context.Context, arg sqlc.UpsertSweepParams) error
}
// BaseDB is the interface that contains all the queries generated
// by sqlc for sweep batcher and transaction functionality.
type BaseDB interface {
Querier
// ExecTx allows for executing a function in the context of a database
// transaction.

Loading…
Cancel
Save