forked from TrueCloudLab/frostfs-node
[#749] neofs-adm: add group scope to force-new-epoch
command
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
e4bc9c7fad
commit
8fa2b364a1
2 changed files with 31 additions and 16 deletions
|
@ -93,20 +93,7 @@ func (c *initializeContext) emitUpdateNNSGroupScript(bw *io.BufBinWriter, nnsHas
|
|||
}
|
||||
|
||||
if !isAvail {
|
||||
item, err := nnsResolve(c.Client, nnsHash, "group.neofs")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
arr, ok := item.Value().([]stackitem.Item)
|
||||
if !ok || len(arr) == 0 {
|
||||
return 0, errors.New("NNS record is missing")
|
||||
}
|
||||
bs, err := arr[0].TryBytes()
|
||||
if err != nil {
|
||||
return 0, errors.New("malformed response")
|
||||
}
|
||||
|
||||
currentPub, err := keys.NewPublicKeyFromString(string(bs))
|
||||
currentPub, err := nnsResolveKey(c.Client, nnsHash, groupKeyDomain)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -220,6 +207,23 @@ func nnsResolve(c *client.Client, nnsHash util.Uint160, domain string) (stackite
|
|||
return result.Stack[len(result.Stack)-1], nil
|
||||
}
|
||||
|
||||
func nnsResolveKey(c *client.Client, nnsHash util.Uint160, domain string) (*keys.PublicKey, error) {
|
||||
item, err := nnsResolve(c, nnsHash, domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
arr, ok := item.Value().([]stackitem.Item)
|
||||
if !ok || len(arr) == 0 {
|
||||
return nil, errors.New("NNS record is missing")
|
||||
}
|
||||
bs, err := arr[0].TryBytes()
|
||||
if err != nil {
|
||||
return nil, errors.New("malformed response")
|
||||
}
|
||||
|
||||
return keys.NewPublicKeyFromString(string(bs))
|
||||
}
|
||||
|
||||
// parseNNSResolveResult parses the result of resolving NNS record.
|
||||
// It works with multiple formats (corresponding to multiple NNS versions).
|
||||
// If array of hashes is provided, it returns only the first one.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue