lit: use db.Store interface instead of raw DB pointer

Give the sessionRpcServer access to the session store via the
session.Store interface instead of the raw DB pointer. This will make it
possible to swop out the implementation (which is currently bbolt) with
something else such as a SQL implementation. We move the responsibility
of closing the DB to the main LiT server.
This commit is contained in:
Elle Mouton 2025-02-09 07:12:06 +02:00
parent 03d03eabfc
commit 29f6db7de6
No known key found for this signature in database
GPG key ID: D7D916376026F177
2 changed files with 8 additions and 5 deletions

View file

@ -58,7 +58,7 @@ type sessionRpcServer struct {
// sessionRpcServerConfig holds the values used to configure the
// sessionRpcServer.
type sessionRpcServerConfig struct {
db *session.BoltStore
db session.Store
basicAuth string
grpcOptions []grpc.ServerOption
registerGrpcServers func(server *grpc.Server)
@ -175,10 +175,6 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
func (s *sessionRpcServer) stop() error {
var returnErr error
s.stopOnce.Do(func() {
if err := s.cfg.db.Close(); err != nil {
log.Errorf("Error closing session DB: %v", err)
returnErr = err
}
s.sessionServer.Stop()
close(s.quit)

View file

@ -1457,6 +1457,13 @@ func (g *LightningTerminal) shutdownSubServers() error {
}
}
if g.sessionDB != nil {
if err := g.sessionDB.Close(); err != nil {
log.Errorf("Error closing session DB: %v", err)
returnErr = err
}
}
if g.lndClient != nil {
g.lndClient.Close()
}