Skip to content

Commit a067bce

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 e235d71 commit a067bce

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
@@ -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.ListSessions()
104+
sessions, err := s.cfg.db.ListSessions(
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
}
@@ -353,16 +350,6 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
353350
pubKey := sess.LocalPublicKey
354351
pubKeyBytes := pubKey.SerializeCompressed()
355352

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

0 commit comments

Comments
 (0)