Skip to content

Commit

Permalink
refactor: sessionKey
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd committed Jan 5, 2023
1 parent 8528e02 commit 4a2d978
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions share/getters/ipld.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (ig *IPLDGetter) GetSharesByNamespace(
return shares, nil
}

type sessionKey struct{}
var sessionKey = session{}

// session is a struct that can optionally be passed by context to the share.Getter methods using
// WithSession to indicate that a blockservice session should be created.
Expand All @@ -116,11 +116,11 @@ type session struct {
// WithSession stores an empty session in the context, indicating that a blockservice session should
// be created.
func WithSession(ctx context.Context) context.Context {
return context.WithValue(ctx, sessionKey{}, &session{})
return context.WithValue(ctx, &sessionKey, &session{})
}

func getGetter(ctx context.Context, service blockservice.BlockService) blockservice.BlockGetter {
s, ok := ctx.Value(sessionKey{}).(*session)
s, ok := ctx.Value(&sessionKey).(*session)
if !ok {
return service
}
Expand Down

0 comments on commit 4a2d978

Please sign in to comment.