forked from TrueCloudLab/frostfs-node
Ekaterina Lebedeva
259007540f
We used several utility functions to parse frostfsid client subject and extended subject. However, following the changes in TrueCloudLab/frostfs-contract#97, these utility functions have become public. So there is no more need to have them here. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package frostfsid
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
)
|
|
|
|
const (
|
|
methodGetSubject = "getSubject"
|
|
methodGetSubjectExtended = "getSubjectExtended"
|
|
)
|
|
|
|
func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
|
|
prm := client.TestInvokePrm{}
|
|
prm.SetMethod(methodGetSubject)
|
|
prm.SetArgs(addr)
|
|
|
|
res, err := c.client.TestInvoke(prm)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not perform test invocation (%s): %w", methodGetSubject, err)
|
|
}
|
|
|
|
subj, err := frostfsidclient.ParseSubject(res)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not parse test invocation result (%s): %w", methodGetSubject, err)
|
|
}
|
|
|
|
return subj, nil
|
|
}
|
|
|
|
func (c *Client) GetSubjectExtended(addr util.Uint160) (*frostfsidclient.SubjectExtended, error) {
|
|
prm := client.TestInvokePrm{}
|
|
prm.SetMethod(methodGetSubjectExtended)
|
|
prm.SetArgs(addr)
|
|
|
|
res, err := c.client.TestInvoke(prm)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not perform test invocation (%s): %w", methodGetSubject, err)
|
|
}
|
|
|
|
subj, err := frostfsidclient.ParseSubjectExtended(res)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not parse test invocation result (%s): %w", methodGetSubject, err)
|
|
}
|
|
|
|
return subj, nil
|
|
}
|