forked from TrueCloudLab/frostfs-node
[#726] neofs-adm: set alphabet contract addresses in NNS
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4d65e138f5
commit
9e56012760
2 changed files with 74 additions and 0 deletions
|
@ -14,6 +14,8 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const lastGlagoliticLetter = 41
|
||||
|
||||
func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
||||
c, err := getN3Client(viper.GetViper())
|
||||
if err != nil {
|
||||
|
@ -40,8 +42,43 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
|||
return errors.New("invalid response from NNS contract: length mismatch")
|
||||
}
|
||||
|
||||
irSize := 0
|
||||
for ; irSize < lastGlagoliticLetter; irSize++ {
|
||||
ok, err := c.NNSIsAvailable(cs.Hash, getAlphabetNNSDomain(irSize))
|
||||
if err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
tw := tabwriter.NewWriter(buf, 0, 2, 2, ' ', 0)
|
||||
|
||||
if irSize != 0 {
|
||||
bw.Reset()
|
||||
for i := 0; i < irSize; i++ {
|
||||
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
|
||||
getAlphabetNNSDomain(i),
|
||||
int64(nns.TXT))
|
||||
}
|
||||
|
||||
alphaRes, err := c.InvokeScript(bw.Bytes(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't fetch info from NNS: %w", err)
|
||||
}
|
||||
|
||||
for i := 0; i < irSize; i++ {
|
||||
ctrHash := "hash is invalid"
|
||||
bs, err := alphaRes.Stack[i].TryBytes()
|
||||
if err == nil {
|
||||
ctrHash = string(bs) // hashes are stored as hex-encoded LE string
|
||||
}
|
||||
|
||||
_, _ = tw.Write([]byte(fmt.Sprintf("alphabet %d:\t%s\n", i, ctrHash)))
|
||||
}
|
||||
}
|
||||
|
||||
for i := range contractList {
|
||||
ctrHash := "hash is invalid"
|
||||
bs, err := res.Stack[i].TryBytes()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue