package zombie import ( "errors" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph" nodeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/node" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" cntClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container" netmapClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap" "github.com/spf13/cobra" ) func createMorphClient(cmd *cobra.Command, appCfg *config.Config) *client.Client { addresses := morphconfig.RPCEndpoint(appCfg) if len(addresses) == 0 { commonCmd.ExitOnErr(cmd, "create morph client: %w", errors.New("no morph endpoints found")) } key := nodeconfig.Key(appCfg) cli, err := client.New(cmd.Context(), key, client.WithDialTimeout(morphconfig.DialTimeout(appCfg)), client.WithEndpoints(addresses...), client.WithSwitchInterval(morphconfig.SwitchInterval(appCfg)), ) commonCmd.ExitOnErr(cmd, "create morph client: %w", err) return cli } func createContainerClient(cmd *cobra.Command, morph *client.Client) *cntClient.Client { hs, err := morph.NNSContractAddress(client.NNSContainerContractName) commonCmd.ExitOnErr(cmd, "resolve container contract hash: %w", err) cc, err := cntClient.NewFromMorph(morph, hs, 0) commonCmd.ExitOnErr(cmd, "create morph container client: %w", err) return cc } func createNetmapClient(cmd *cobra.Command, morph *client.Client) *netmapClient.Client { hs, err := morph.NNSContractAddress(client.NNSNetmapContractName) commonCmd.ExitOnErr(cmd, "resolve netmap contract hash: %w", err) cli, err := netmapClient.NewFromMorph(morph, hs, 0) commonCmd.ExitOnErr(cmd, "create morph netmap client: %w", err) return cli }