forked from TrueCloudLab/frostfs-node
[#88] adm: Fix method nnsResolveKey
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
f1f3c80dbf
commit
7486c02bbc
1 changed files with 14 additions and 7 deletions
|
@ -228,20 +228,27 @@ func nnsResolve(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (stac
|
||||||
}
|
}
|
||||||
|
|
||||||
func nnsResolveKey(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (*keys.PublicKey, error) {
|
func nnsResolveKey(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (*keys.PublicKey, error) {
|
||||||
item, err := nnsResolve(inv, nnsHash, domain)
|
res, err := nnsResolve(inv, nnsHash, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
v, ok := item.Value().(stackitem.Null)
|
if _, ok := res.Value().(stackitem.Null); ok {
|
||||||
if ok {
|
|
||||||
return nil, errors.New("NNS record is missing")
|
return nil, errors.New("NNS record is missing")
|
||||||
}
|
}
|
||||||
bs, err := v.TryBytes()
|
arr, ok := res.Value().([]stackitem.Item)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("API of the NNS contract method `resolve` has changed")
|
||||||
|
}
|
||||||
|
for i := range arr {
|
||||||
|
var bs []byte
|
||||||
|
bs, err = arr[i].TryBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("malformed response")
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys.NewPublicKeyFromString(string(bs))
|
return keys.NewPublicKeyFromString(string(bs))
|
||||||
|
}
|
||||||
|
return nil, errors.New("no valid keys are found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseNNSResolveResult parses the result of resolving NNS record.
|
// parseNNSResolveResult parses the result of resolving NNS record.
|
||||||
|
|
Loading…
Reference in a new issue