Skip to content

Commit 9c48b0b

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 9c48b0b

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

session_rpcserver.go

Lines changed: 4 additions & 17 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
}
@@ -125,12 +128,6 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
125128
continue
126129
}
127130

128-
if sess.State != session.StateInUse &&
129-
sess.State != session.StateCreated {
130-
131-
continue
132-
}
133-
134131
if sess.Expiry.Before(time.Now()) {
135132
continue
136133
}
@@ -356,16 +353,6 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
356353
pubKey := sess.LocalPublicKey
357354
pubKeyBytes := pubKey.SerializeCompressed()
358355

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-
369356
// Don't resume an expired session.
370357
if sess.Expiry.Before(time.Now()) {
371358
log.Debugf("Not resuming session %x with expiry %s",

0 commit comments

Comments
 (0)