Skip to content

Commit a586a55

Browse files
committed
lit: only fetch active sessions on startup
Using the new ListSessions by type method, we no longer need to fetch and iterate through all our sessions on start up to figure out which ones to spin up.
1 parent 980a36d commit a586a55

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

session_rpcserver.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
100100
// requests. This includes resuming all non-revoked sessions.
101101
func (s *sessionRpcServer) start(ctx context.Context) error {
102102
// Start up all previously created sessions.
103-
sessions, err := s.cfg.db.ListSessions()
103+
sessions, err := s.cfg.db.ListSessions(
104+
session.StateCreated,
105+
session.StateInUse,
106+
)
104107
if err != nil {
105108
return fmt.Errorf("error listing sessions: %v", err)
106109
}
@@ -356,16 +359,6 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
356359
pubKey := sess.LocalPublicKey
357360
pubKeyBytes := pubKey.SerializeCompressed()
358361

359-
// We only start non-revoked, non-expired LiT sessions. Everything else
360-
// we just skip.
361-
if sess.State != session.StateInUse &&
362-
sess.State != session.StateCreated {
363-
364-
log.Debugf("Not resuming session %x with state %d", pubKeyBytes,
365-
sess.State)
366-
return nil
367-
}
368-
369362
// Don't resume an expired session.
370363
if sess.Expiry.Before(time.Now()) {
371364
log.Debugf("Not resuming session %x with expiry %s",

0 commit comments

Comments
 (0)