forked from TrueCloudLab/frostfs-node
[#156] frostfs-adm: Make dumpBalances() pass linter checks
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
8014fdb21a
commit
484ac502ca
1 changed files with 87 additions and 64 deletions
|
@ -44,7 +44,6 @@ const (
|
|||
notaryEnabled = true
|
||||
)
|
||||
|
||||
// nolint: funlen, gocognit
|
||||
func dumpBalances(cmd *cobra.Command, _ []string) error {
|
||||
var (
|
||||
dumpStorage, _ = cmd.Flags().GetBool(dumpBalancesStorageFlag)
|
||||
|
@ -84,6 +83,27 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
|
|||
printBalances(cmd, "Inner ring nodes balances:", irList)
|
||||
|
||||
if dumpStorage {
|
||||
if err := printStorageNodeBalances(cmd, inv, nmHash); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if dumpProxy {
|
||||
if err := printProxyContractBalance(cmd, inv, nnsCs.Hash); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if dumpAlphabet {
|
||||
if err := printAlphabetContractBalances(cmd, c, inv, len(irList), nnsCs.Hash); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func printStorageNodeBalances(cmd *cobra.Command, inv *invoker.Invoker, nmHash util.Uint160) error {
|
||||
arr, err := unwrap.Array(inv.Call(nmHash, "netmap"))
|
||||
if err != nil {
|
||||
return errors.New("can't fetch the list of storage nodes")
|
||||
|
@ -113,11 +133,13 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
|
|||
if err := fetchBalances(inv, gas.Hash, snList); err != nil {
|
||||
return err
|
||||
}
|
||||
printBalances(cmd, "\nStorage node balances:", snList)
|
||||
}
|
||||
|
||||
if dumpProxy {
|
||||
h, err := nnsResolveHash(inv, nnsCs.Hash, proxyContract+".frostfs")
|
||||
printBalances(cmd, "\nStorage node balances:", snList)
|
||||
return nil
|
||||
}
|
||||
|
||||
func printProxyContractBalance(cmd *cobra.Command, inv *invoker.Invoker, nnsHash util.Uint160) error {
|
||||
h, err := nnsResolveHash(inv, nnsHash, proxyContract+".frostfs")
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't get hash of the proxy contract: %w", err)
|
||||
}
|
||||
|
@ -126,15 +148,17 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
|
|||
if err := fetchBalances(inv, gas.Hash, proxyList); err != nil {
|
||||
return err
|
||||
}
|
||||
printBalances(cmd, "\nProxy contract balance:", proxyList)
|
||||
}
|
||||
|
||||
if dumpAlphabet {
|
||||
alphaList := make([]accBalancePair, len(irList))
|
||||
printBalances(cmd, "\nProxy contract balance:", proxyList)
|
||||
return nil
|
||||
}
|
||||
|
||||
func printAlphabetContractBalances(cmd *cobra.Command, c Client, inv *invoker.Invoker, count int, nnsHash util.Uint160) error {
|
||||
alphaList := make([]accBalancePair, count)
|
||||
|
||||
w := io.NewBufBinWriter()
|
||||
for i := range alphaList {
|
||||
emit.AppCall(w.BinWriter, nnsCs.Hash, "resolve", callflag.ReadOnly,
|
||||
emit.AppCall(w.BinWriter, nnsHash, "resolve", callflag.ReadOnly,
|
||||
getAlphabetNNSDomain(i),
|
||||
int64(nns.TXT))
|
||||
}
|
||||
|
@ -158,9 +182,8 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
|
|||
if err := fetchBalances(inv, gas.Hash, alphaList); err != nil {
|
||||
return err
|
||||
}
|
||||
printBalances(cmd, "\nAlphabet contracts balances:", alphaList)
|
||||
}
|
||||
|
||||
printBalances(cmd, "\nAlphabet contracts balances:", alphaList)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue