From 86a4fba571eb92296bf6826017665f09be43b9de Mon Sep 17 00:00:00 2001
From: Pavel Karpy
Date: Wed, 21 Dec 2022 19:14:05 +0300
Subject: [PATCH] [#2144] node: Clarify `KeyStorage.GetKey` method
Actualize the doc, fix API status error return.
Signed-off-by: Pavel Karpy
---
pkg/services/object/util/key.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pkg/services/object/util/key.go b/pkg/services/object/util/key.go
index 9cad7c064..313678bb3 100644
--- a/pkg/services/object/util/key.go
+++ b/pkg/services/object/util/key.go
@@ -51,10 +51,13 @@ type SessionInfo struct {
Owner user.ID
}
-// GetKey returns private key of the node.
+// GetKey fetches private key depending on the SessionInfo.
//
-// If token is not nil, session private key is returned.
-// Otherwise, node private key is returned.
+// If info is not `nil`, searches for dynamic session token through the
+// underlying token storage. Returns apistatus.SessionTokenNotFound if
+// token storage does not contain information about provided dynamic session.
+//
+// If info is `nil`, returns node's private key.
func (s *KeyStorage) GetKey(info *SessionInfo) (*ecdsa.PrivateKey, error) {
if info != nil {
binID, err := info.ID.MarshalBinary()