forked from TrueCloudLab/frostfs-node
[#932] adm: Move command dump-balances
to package balance
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
8148c9dc19
commit
beb9d80e34
7 changed files with 41 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
|||
package morph
|
||||
package balance
|
||||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
|
@ -157,7 +157,7 @@ func printAlphabetContractBalances(cmd *cobra.Command, c morphUtil.Client, inv *
|
|||
w := io.NewBufBinWriter()
|
||||
for i := range alphaList {
|
||||
emit.AppCall(w.BinWriter, nnsHash, "resolve", callflag.ReadOnly,
|
||||
getAlphabetNNSDomain(i),
|
||||
morphUtil.GetAlphabetNNSDomain(i),
|
||||
int64(nns.TXT))
|
||||
}
|
||||
if w.Err != nil {
|
28
cmd/frostfs-adm/internal/modules/morph/balance/root.go
Normal file
28
cmd/frostfs-adm/internal/modules/morph/balance/root.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package balance
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var DumpCmd = &cobra.Command{
|
||||
Use: "dump-balances",
|
||||
Short: "Dump GAS balances",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
||||
},
|
||||
RunE: dumpBalances,
|
||||
}
|
||||
|
||||
func initDumpBalancesCmd() {
|
||||
DumpCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
||||
DumpCmd.Flags().BoolP(dumpBalancesStorageFlag, "s", false, "Dump balances of storage nodes from the current netmap")
|
||||
DumpCmd.Flags().BoolP(dumpBalancesAlphabetFlag, "a", false, "Dump balances of alphabet contracts")
|
||||
DumpCmd.Flags().BoolP(dumpBalancesProxyFlag, "p", false, "Dump balances of the proxy contract")
|
||||
DumpCmd.Flags().Bool(dumpBalancesUseScriptHashFlag, false, "Use script-hash format for addresses")
|
||||
}
|
||||
|
||||
func init() {
|
||||
initDumpBalancesCmd()
|
||||
}
|
|
@ -54,7 +54,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
|||
|
||||
irSize := 0
|
||||
for ; irSize < lastGlagoliticLetter; irSize++ {
|
||||
ok, err := morphUtil.NNSIsAvailable(c, cs.Hash, getAlphabetNNSDomain(irSize))
|
||||
ok, err := morphUtil.NNSIsAvailable(c, cs.Hash, morphUtil.GetAlphabetNNSDomain(irSize))
|
||||
if err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
|
@ -68,7 +68,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
|||
bw.Reset()
|
||||
for i := 0; i < irSize; i++ {
|
||||
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
|
||||
getAlphabetNNSDomain(i),
|
||||
morphUtil.GetAlphabetNNSDomain(i),
|
||||
int64(nns.TXT))
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash util.Uint160
|
|||
|
||||
// alphabet contracts should be deployed by individual nodes to get different hashes.
|
||||
for i, acc := range c.Accounts {
|
||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, getAlphabetNNSDomain(i))
|
||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.GetAlphabetNNSDomain(i))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't resolve hash for contract update: %w", err)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||
|
@ -48,7 +47,7 @@ func setNNS(c *morphUtil.InitializeContext) error {
|
|||
for i, acc := range c.Accounts {
|
||||
alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
||||
|
||||
domain := getAlphabetNNSDomain(i)
|
||||
domain := morphUtil.GetAlphabetNNSDomain(i)
|
||||
if err := nnsRegisterDomain(c, nnsCs.Hash, alphaCs.Hash, domain); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -93,10 +92,6 @@ func updateNNSGroup(c *morphUtil.InitializeContext, nnsHash util.Uint160, pub *k
|
|||
return c.SendCommitteeTx(script, true)
|
||||
}
|
||||
|
||||
func getAlphabetNNSDomain(i int) string {
|
||||
return morphUtil.AlphabetContract + strconv.FormatUint(uint64(i), 10) + ".frostfs"
|
||||
}
|
||||
|
||||
// wrapRegisterScriptWithPrice wraps a given script with `getPrice`/`setPrice` calls for NNS.
|
||||
// It is intended to be used for a single transaction, and not as a part of other scripts.
|
||||
// It is assumed that script already contains static slot initialization code, the first one
|
||||
|
|
|
@ -2,6 +2,7 @@ package morph
|
|||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/ape"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/balance"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/frostfsid"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/policy"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/proxy"
|
||||
|
@ -151,15 +152,6 @@ var (
|
|||
RunE: dumpNetworkConfig,
|
||||
}
|
||||
|
||||
dumpBalancesCmd = &cobra.Command{
|
||||
Use: "dump-balances",
|
||||
Short: "Dump GAS balances",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
||||
},
|
||||
RunE: dumpBalances,
|
||||
}
|
||||
|
||||
updateContractsCmd = &cobra.Command{
|
||||
Use: "update-contracts",
|
||||
Short: "Update FrostFS contracts",
|
||||
|
@ -230,7 +222,7 @@ func init() {
|
|||
initDumpContractHashesCmd()
|
||||
initDumpNetworkConfigCmd()
|
||||
initSetConfigCmd()
|
||||
initDumpBalancesCmd()
|
||||
RootCmd.AddCommand(balance.DumpCmd)
|
||||
initUpdateContractsCmd()
|
||||
initDumpContainersCmd()
|
||||
initRestoreContainersCmd()
|
||||
|
@ -301,15 +293,6 @@ func initUpdateContractsCmd() {
|
|||
updateContractsCmd.MarkFlagsMutuallyExclusive(util.ContractsInitFlag, util.ContractsURLFlag)
|
||||
}
|
||||
|
||||
func initDumpBalancesCmd() {
|
||||
RootCmd.AddCommand(dumpBalancesCmd)
|
||||
dumpBalancesCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
||||
dumpBalancesCmd.Flags().BoolP(dumpBalancesStorageFlag, "s", false, "Dump balances of storage nodes from the current netmap")
|
||||
dumpBalancesCmd.Flags().BoolP(dumpBalancesAlphabetFlag, "a", false, "Dump balances of alphabet contracts")
|
||||
dumpBalancesCmd.Flags().BoolP(dumpBalancesProxyFlag, "p", false, "Dump balances of the proxy contract")
|
||||
dumpBalancesCmd.Flags().Bool(dumpBalancesUseScriptHashFlag, false, "Use script-hash format for addresses")
|
||||
}
|
||||
|
||||
func initSetConfigCmd() {
|
||||
RootCmd.AddCommand(setConfig)
|
||||
setConfig.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||
|
@ -157,3 +158,7 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
|
|||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func GetAlphabetNNSDomain(i int) string {
|
||||
return AlphabetContract + strconv.FormatUint(uint64(i), 10) + ".frostfs"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue