adm: Add command morph netmap-candidates
#15
|
@ -8,6 +8,7 @@ Changelog for FrostFS Node
|
|||
- Doc for extended headers (#2128)
|
||||
- New `frostfs_node_object_container_size` metric for tracking size of reqular objects in a container (#2116)
|
||||
- New `frostfs_node_object_payload_size` metric for tracking size of reqular objects on a single shard (#1794)
|
||||
- Add command `frostfs-adm morph netmap-candidates` (#1889)
|
||||
|
||||
### Changed
|
||||
- `common.PrintVerbose` prints via `cobra.Command.Printf` (#1962)
|
||||
|
|
|
@ -4,4 +4,8 @@ const (
|
|||
ConfigFlag = "config"
|
||||
ConfigFlagShorthand = "c"
|
||||
ConfigFlagUsage = "Config file"
|
||||
|
||||
Verbose = "verbose"
|
||||
VerboseShorthand = "v"
|
||||
VerboseUsage = "Verbose output"
|
||||
)
|
||||
|
|
29
cmd/frostfs-adm/internal/modules/morph/netmap_candidates.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
package morph
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
import (
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd "github.com/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
"github.com/spf13/cobra"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
"github.com/spf13/viper"
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
func listNetmapCandidatesNodes(cmd *cobra.Command, _ []string) {
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
c, err := getN3Client(viper.GetViper())
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.ExitOnErr(cmd, "can't create N3 client: %w", err)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
inv := invoker.New(c, nil)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
cs, err := c.GetContractStateByID(1)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.ExitOnErr(cmd, "can't get NNS contract info: %w", err)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
nmHash, err := nnsResolveHash(inv, cs.Hash, netmapContract+".frostfs")
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.ExitOnErr(cmd, "can't get netmap contract hash: %w", err)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
res, err := inv.Call(nmHash, "netmapCandidates")
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.ExitOnErr(cmd, "can't fetch list of network config keys from the netmap contract", err)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
nm, err := netmap.DecodeNetMap(res.Stack)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.ExitOnErr(cmd, "unable to decode netmap: %w", err)
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
commonCmd.PrettyPrintNetMap(cmd, *nm, !viper.GetBool(commonflags.Verbose))
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
||||
}
|
||||
lets try not to use lets try not to use `RunE` according to #623?
why do we need it? why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see that context is usually used for complex transactions. for RO purposes it looks too heavy, see `morph dump-config` as an example
Refactored. Refactored.
Removed. Removed.
Refactored. Refactored.
Is it possible to have Is it possible to have `res == nil` and `err == nil` at the same time?
Removed redundant check. Removed redundant check.
|
|
@ -226,6 +226,16 @@ var (
|
|||
},
|
||||
RunE: depositNotary,
|
||||
}
|
||||
|
||||
netmapCandidatesCmd = &cobra.Command{
|
||||
Use: "netmap-candidates",
|
||||
Short: "List netmap candidates nodes",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag))
|
||||
_ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag))
|
||||
},
|
||||
Run: listNetmapCandidatesNodes,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -323,4 +333,7 @@ func init() {
|
|||
depositNotaryCmd.Flags().String(walletAccountFlag, "", "Wallet account address")
|
||||
depositNotaryCmd.Flags().String(refillGasAmountFlag, "", "Amount of GAS to deposit")
|
||||
Why not short by default and Why not short by default and `--verbose` for everything?
Good idea, replaced with Good idea, replaced with `--verbose`.
|
||||
depositNotaryCmd.Flags().String(notaryDepositTillFlag, "", "Notary deposit duration in blocks")
|
||||
|
||||
RootCmd.AddCommand(netmapCandidatesCmd)
|
||||
netmapCandidatesCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint")
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ func init() {
|
|||
rootCmd.SetOut(os.Stdout)
|
||||
|
||||
rootCmd.PersistentFlags().StringP(commonflags.ConfigFlag, commonflags.ConfigFlagShorthand, "", commonflags.ConfigFlagUsage)
|
||||
rootCmd.PersistentFlags().BoolP(commonflags.Verbose, commonflags.VerboseShorthand, false, commonflags.VerboseUsage)
|
||||
_ = viper.BindPFlag(commonflags.Verbose, rootCmd.PersistentFlags().Lookup(commonflags.Verbose))
|
||||
rootCmd.Flags().Bool("version", false, "Application version")
|
||||
|
||||
rootCmd.AddCommand(config.RootCmd)
|
||||
|
|
|
@ -22,7 +22,7 @@ func (c *Client) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
|
|||
epochSnapshotMethod, err)
|
||||
}
|
||||
|
||||
nm, err := decodeNetMap(res)
|
||||
nm, err := DecodeNetMap(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ func (c *Client) NetMap() (*netmap.NetMap, error) {
|
|||
netMapMethod, err)
|
||||
}
|
||||
|
||||
return decodeNetMap(res)
|
||||
return DecodeNetMap(res)
|
||||
}
|
||||
|
||||
func decodeNetMap(resStack []stackitem.Item) (*netmap.NetMap, error) {
|
||||
func DecodeNetMap(resStack []stackitem.Item) (*netmap.NetMap, error) {
|
||||
var nm netmap.NetMap
|
||||
|
||||
if len(resStack) > 0 {
|
||||
|
|
|
@ -16,5 +16,5 @@ func (c *Client) GetNetMap(diff uint64) (*netmap.NetMap, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return decodeNetMap(res)
|
||||
return DecodeNetMap(res)
|
||||
}
|
||||
|
|
lets try not to use
RunE
according to #623?why do we need it?
that context is usually used for complex transactions. for RO purposes it looks too heavy, see
morph dump-config
as an example