mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
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.
This commit is contained in:
parent
d2b077b9d5
commit
14cb0be3bc
1 changed files with 5 additions and 19 deletions
|
|
@ -101,7 +101,10 @@ func newSessionRPCServer(cfg *sessionRpcServerConfig) (*sessionRpcServer,
|
|||
// requests. This includes resuming all non-revoked sessions.
|
||||
func (s *sessionRpcServer) start(ctx context.Context) error {
|
||||
// Start up all previously created sessions.
|
||||
sessions, err := s.cfg.db.ListAllSessions()
|
||||
sessions, err := s.cfg.db.ListSessionsByState(
|
||||
session.StateCreated,
|
||||
session.StateInUse,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error listing sessions: %v", err)
|
||||
}
|
||||
|
|
@ -126,12 +129,6 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
|
||||
if sess.State != session.StateInUse &&
|
||||
sess.State != session.StateCreated {
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if sess.Expiry.Before(time.Now()) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -345,24 +342,13 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
|
|||
}, nil
|
||||
}
|
||||
|
||||
// resumeSession tries to start an existing session if it is not expired, not
|
||||
// revoked and a LiT session.
|
||||
// resumeSession tries to start the given session if it is not expired.
|
||||
func (s *sessionRpcServer) resumeSession(ctx context.Context,
|
||||
sess *session.Session) error {
|
||||
|
||||
pubKey := sess.LocalPublicKey
|
||||
pubKeyBytes := pubKey.SerializeCompressed()
|
||||
|
||||
// We only start non-revoked, non-expired LiT sessions. Everything else
|
||||
// we just skip.
|
||||
if sess.State != session.StateInUse &&
|
||||
sess.State != session.StateCreated {
|
||||
|
||||
log.Debugf("Not resuming session %x with state %d", pubKeyBytes,
|
||||
sess.State)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Don't resume an expired session.
|
||||
if sess.Expiry.Before(time.Now()) {
|
||||
log.Debugf("Not resuming session %x with expiry %s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue