Skip to content

Commit 29f6db7

Browse files
committed
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.
1 parent 03d03ea commit 29f6db7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

session_rpcserver.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type sessionRpcServer struct {
5858
// sessionRpcServerConfig holds the values used to configure the
5959
// sessionRpcServer.
6060
type sessionRpcServerConfig struct {
61-
db *session.BoltStore
61+
db session.Store
6262
basicAuth string
6363
grpcOptions []grpc.ServerOption
6464
registerGrpcServers func(server *grpc.Server)
@@ -175,10 +175,6 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
175175
func (s *sessionRpcServer) stop() error {
176176
var returnErr error
177177
s.stopOnce.Do(func() {
178-
if err := s.cfg.db.Close(); err != nil {
179-
log.Errorf("Error closing session DB: %v", err)
180-
returnErr = err
181-
}
182178
s.sessionServer.Stop()
183179

184180
close(s.quit)

terminal.go

+7
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,13 @@ func (g *LightningTerminal) shutdownSubServers() error {
14571457
}
14581458
}
14591459

1460+
if g.sessionDB != nil {
1461+
if err := g.sessionDB.Close(); err != nil {
1462+
log.Errorf("Error closing session DB: %v", err)
1463+
returnErr = err
1464+
}
1465+
}
1466+
14601467
if g.lndClient != nil {
14611468
g.lndClient.Close()
14621469
}

0 commit comments

Comments
 (0)