session+lnrpc: add StateReserved and delete these on start up

This commit is contained in:
Elle Mouton 2025-02-09 12:49:01 +02:00
parent 68ae704229
commit 6717d9d54b
No known key found for this signature in database
GPG key ID: D7D916376026F177
11 changed files with 210 additions and 33 deletions

View file

@ -100,6 +100,12 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
// start all the components necessary for the sessionRpcServer to start serving
// requests. This includes resuming all non-revoked sessions.
func (s *sessionRpcServer) start(ctx context.Context) error {
// Delete all sessions in the Reserved state.
err := s.cfg.db.DeleteReservedSessions()
if err != nil {
return fmt.Errorf("error deleting reserved sessions: %v", err)
}
// Start up all previously created sessions.
sessions, err := s.cfg.db.ListSessionsByState(
session.StateCreated,
@ -1518,6 +1524,9 @@ func marshalRPCMacaroonRecipe(
// marshalRPCState converts a session state to its RPC counterpart.
func marshalRPCState(state session.State) (litrpc.SessionState, error) {
switch state {
case session.StateReserved:
return litrpc.SessionState_STATE_RESERVED, nil
case session.StateCreated:
return litrpc.SessionState_STATE_CREATED, nil