From e468f409d7101b1352ebac362e7e57c0a576ad70 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 26 Apr 2022 12:52:01 +0300 Subject: [PATCH] [#197] pool: Remove unused function parameter `owner.ID` parameter of `createSessionTokenForDuration` function is no longer used since session owner is set automatically during the sign operation. As a consequence, remove `Pool.sessionOwner` field and its getter. Signed-off-by: Leonard Lyubich --- pool/pool.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index bf1a0438..f5aa2d57 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -904,7 +904,6 @@ type resCreateSession struct { type Pool struct { innerPools []*innerPool key *ecdsa.PrivateKey - sessionOwner user.ID cancel context.CancelFunc closedCh chan struct{} cache *sessionCache @@ -959,8 +958,6 @@ func NewPool(options InitParameters) (*Pool, error) { clientBuilder: options.clientBuilder, } - user.IDFromKey(&pool.sessionOwner, options.key.PublicKey) - return pool, nil } @@ -984,7 +981,7 @@ func (p *Pool) Dial(ctx context.Context) error { return err } var healthy bool - st, err := createSessionTokenForDuration(ctx, c, p.sessionOwner, p.rebalanceParams.sessionExpirationDuration) + st, err := createSessionTokenForDuration(ctx, c, p.rebalanceParams.sessionExpirationDuration) if err != nil && p.logger != nil { p.logger.Warn("failed to create neofs session token for client", zap.String("Address", addr), @@ -1207,10 +1204,6 @@ func (p *innerPool) connection() (*clientPack, error) { return nil, errors.New("no healthy client") } -func (p *Pool) OwnerID() *user.ID { - return &p.sessionOwner -} - func formCacheKey(address string, key *ecdsa.PrivateKey) string { k := keys.PrivateKey{PrivateKey: *key} return address + k.String() @@ -1230,7 +1223,7 @@ func (p *Pool) checkSessionTokenErr(err error, address string) bool { return false } -func createSessionTokenForDuration(ctx context.Context, c client, ownerID user.ID, dur uint64) (*session.Object, error) { +func createSessionTokenForDuration(ctx context.Context, c client, dur uint64) (*session.Object, error) { ni, err := c.networkInfo(ctx, prmNetworkInfo{}) if err != nil { return nil, err @@ -1330,12 +1323,9 @@ func (p *Pool) openDefaultSession(ctx *callContext) error { tok, ok := p.cache.Get(cacheKey) if !ok { var err error - var sessionOwner user.ID - - user.IDFromKey(&sessionOwner, ctx.key.PublicKey) // open new session - t, err := createSessionTokenForDuration(ctx, ctx.client, sessionOwner, p.stokenDuration) + t, err := createSessionTokenForDuration(ctx, ctx.client, p.stokenDuration) if err != nil { return fmt.Errorf("session API client: %w", err) }