[#2144] node: Clarify KeyStorage.GetKey method

Actualize the doc, fix API status error return.

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2022-12-21 19:14:05 +03:00 committed by Anton Nikiforov
parent b7a99c757a
commit 86a4fba571

View file

@ -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()