Skip to content

Commit 14cb0be

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 d2b077b commit 14cb0be

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

session_rpcserver.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
101101
// requests. This includes resuming all non-revoked sessions.
102102
func (s *sessionRpcServer) start(ctx context.Context) error {
103103
// Start up all previously created sessions.
104-
sessions, err := s.cfg.db.ListAllSessions()
104+
sessions, err := s.cfg.db.ListSessionsByState(
105+
session.StateCreated,
106+
session.StateInUse,
107+
)
105108
if err != nil {
106109
return fmt.Errorf("error listing sessions: %v", err)
107110
}
@@ -126,12 +129,6 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
126129
continue
127130
}
128131

129-
if sess.State != session.StateInUse &&
130-
sess.State != session.StateCreated {
131-
132-
continue
133-
}
134-
135132
if sess.Expiry.Before(time.Now()) {
136133
continue
137134
}
@@ -345,24 +342,13 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
345342
}, nil
346343
}
347344

348-
// resumeSession tries to start an existing session if it is not expired, not
349-
// revoked and a LiT session.
345+
// resumeSession tries to start the given session if it is not expired.
350346
func (s *sessionRpcServer) resumeSession(ctx context.Context,
351347
sess *session.Session) error {
352348

353349
pubKey := sess.LocalPublicKey
354350
pubKeyBytes := pubKey.SerializeCompressed()
355351

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

0 commit comments

Comments
 (0)