Skip to content

Commit 1ba381c

Browse files
committed
session: rename GetSession method
Rename it to GetSessionByLocalPub so that it is more accurately named and so that we free up the GetSession name for future use.
1 parent b65e703 commit 1ba381c

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

session/interface.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ type Store interface {
294294
expiry time.Time, serverAddr string, opts ...Option) (*Session,
295295
error)
296296

297-
// GetSession fetches the session with the given key.
298-
GetSession(ctx context.Context, key *btcec.PublicKey) (*Session, error)
297+
// GetSessionByLocalPub fetches the session with the given local pub
298+
// key.
299+
GetSessionByLocalPub(ctx context.Context,
300+
key *btcec.PublicKey) (*Session, error)
299301

300302
// ListAllSessions returns all sessions currently known to the store.
301303
ListAllSessions(ctx context.Context) ([]*Session, error)

session/kvdb_store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ func (db *BoltStore) UpdateSessionRemotePubKey(_ context.Context, localPubKey,
331331
})
332332
}
333333

334-
// GetSession fetches the session with the given key.
334+
// GetSessionByLocalPub fetches the session with the given local pub key.
335335
//
336336
// NOTE: this is part of the Store interface.
337-
func (db *BoltStore) GetSession(_ context.Context, key *btcec.PublicKey) (
338-
*Session, error) {
337+
func (db *BoltStore) GetSessionByLocalPub(_ context.Context,
338+
key *btcec.PublicKey) (*Session, error) {
339339

340340
var session *Session
341341
err := db.View(func(tx *bbolt.Tx) error {

session/store_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestBasicSessionStore(t *testing.T) {
8282
// Ensure that we can retrieve each session by both its local pub key
8383
// and by its ID.
8484
for _, s := range []*Session{s1, s2, s3} {
85-
session, err := db.GetSession(ctx, s.LocalPublicKey)
85+
session, err := db.GetSessionByLocalPub(ctx, s.LocalPublicKey)
8686
require.NoError(t, err)
8787
assertEqualSessions(t, s, session)
8888

@@ -92,7 +92,7 @@ func TestBasicSessionStore(t *testing.T) {
9292
}
9393

9494
// Fetch session 1 and assert that it currently has no remote pub key.
95-
session1, err := db.GetSession(ctx, s1.LocalPublicKey)
95+
session1, err := db.GetSessionByLocalPub(ctx, s1.LocalPublicKey)
9696
require.NoError(t, err)
9797
require.Nil(t, session1.RemotePublicKey)
9898

@@ -107,7 +107,7 @@ func TestBasicSessionStore(t *testing.T) {
107107
require.NoError(t, err)
108108

109109
// Assert that the session now does have the remote pub key.
110-
session1, err = db.GetSession(ctx, s1.LocalPublicKey)
110+
session1, err = db.GetSessionByLocalPub(ctx, s1.LocalPublicKey)
111111
require.NoError(t, err)
112112
require.True(t, remotePub.IsEqual(session1.RemotePublicKey))
113113

@@ -116,7 +116,7 @@ func TestBasicSessionStore(t *testing.T) {
116116

117117
// Now revoke the session and assert that the state is revoked.
118118
require.NoError(t, db.ShiftState(ctx, s1.ID, StateRevoked))
119-
s1, err = db.GetSession(ctx, s1.LocalPublicKey)
119+
s1, err = db.GetSessionByLocalPub(ctx, s1.LocalPublicKey)
120120
require.NoError(t, err)
121121
require.Equal(t, s1.State, StateRevoked)
122122

@@ -299,7 +299,7 @@ func TestStateShift(t *testing.T) {
299299

300300
// Check that the session is in the StateCreated state. Also check that
301301
// the "RevokedAt" time has not yet been set.
302-
s1, err := db.GetSession(ctx, s1.LocalPublicKey)
302+
s1, err := db.GetSessionByLocalPub(ctx, s1.LocalPublicKey)
303303
require.NoError(t, err)
304304
require.Equal(t, StateCreated, s1.State)
305305
require.Equal(t, time.Time{}, s1.RevokedAt)
@@ -310,7 +310,7 @@ func TestStateShift(t *testing.T) {
310310

311311
// This should have worked. Since it is now in a terminal state, the
312312
// "RevokedAt" time should be set.
313-
s1, err = db.GetSession(ctx, s1.LocalPublicKey)
313+
s1, err = db.GetSessionByLocalPub(ctx, s1.LocalPublicKey)
314314
require.NoError(t, err)
315315
require.Equal(t, StateRevoked, s1.State)
316316
require.True(t, clock.Now().Equal(s1.RevokedAt))

session_rpcserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ func (s *sessionRpcServer) RevokeSession(ctx context.Context,
577577
return nil, fmt.Errorf("error parsing public key: %v", err)
578578
}
579579

580-
sess, err := s.cfg.db.GetSession(ctx, pubKey)
580+
sess, err := s.cfg.db.GetSessionByLocalPub(ctx, pubKey)
581581
if err != nil {
582582
return nil, fmt.Errorf("error fetching session: %v", err)
583583
}
@@ -1319,7 +1319,7 @@ func (s *sessionRpcServer) RevokeAutopilotSession(ctx context.Context,
13191319
return nil, fmt.Errorf("error parsing public key: %v", err)
13201320
}
13211321

1322-
sess, err := s.cfg.db.GetSession(ctx, pubKey)
1322+
sess, err := s.cfg.db.GetSessionByLocalPub(ctx, pubKey)
13231323
if err != nil {
13241324
return nil, err
13251325
}

0 commit comments

Comments
 (0)