From 47f98258058b7b43701217138e7f41b593183cbe Mon Sep 17 00:00:00 2001 From: Jayash Satolia Date: Sat, 2 Nov 2024 23:17:30 +0530 Subject: [PATCH] Update blobber version reset --- cmd/storage.go | 37 +++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/cmd/storage.go b/cmd/storage.go index 4eafcf31..7f65222d 100644 --- a/cmd/storage.go +++ b/cmd/storage.go @@ -385,12 +385,45 @@ var resetBlobberStatsCmd = &cobra.Command{ }, } +var resetVersionCmd = &cobra.Command{ + Use: "reset-version", + Short: "Reset blobber version", + Long: `Reset blobber version`, + Args: cobra.MinimumNArgs(0), + Run: func(cmd *cobra.Command, args []string) { + var ( + flags = cmd.Flags() + + blobberID string + err error + ) + + if !flags.Changed("blobber_id") { + log.Fatal("missing required 'blobber_id' flag") + } + if blobberID, err = flags.GetString("blobber_id"); err != nil { + log.Fatal("error in 'blobber_id' flag: ", err) + } + + snv := sdk.StorageNodeVersion{ + Id: blobberID, + } + + _, _, err = sdk.ResetBlobberVersion(&snv) + if err != nil { + log.Fatal(err) + } + fmt.Println("reset blobber version successfully") + }, +} + func init() { rootCmd.AddCommand(scConfig) rootCmd.AddCommand(lsBlobers) rootCmd.AddCommand(blobberInfoCmd) rootCmd.AddCommand(blobberUpdateCmd) rootCmd.AddCommand(resetBlobberStatsCmd) + rootCmd.AddCommand(resetVersionCmd) scConfig.Flags().Bool("json", false, "(default false) pass this option to print response as json data") lsBlobers.Flags().Bool("json", false, "(default false) pass this option to print response as json data") @@ -429,4 +462,8 @@ func init() { resetBlobberStatsCmd.MarkFlagRequired("prev_saved_data") resetBlobberStatsCmd.MarkFlagRequired("new_allocated") resetBlobberStatsCmd.MarkFlagRequired("new_saved_data") + + resetVersionCmd.Flags().String("blobber_id", "", "blobber_id is required") + resetVersionCmd.MarkFlagRequired("blobber_id") + } diff --git a/go.mod b/go.mod index bda53c46..d90255a7 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.5 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.18.0-RC9 + github.com/0chain/gosdk v1.18.0-RC9.0.20241102174613-5e66d116bc76 github.com/icza/bitio v1.1.0 github.com/olekukonko/tablewriter v0.0.5 github.com/spf13/cobra v1.6.0 diff --git a/go.sum b/go.sum index c9083279..b119a4e4 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v1.18.2 h1:VGWfd3Xqio9xbmebPFnUbuk5QN0pK0xzvifaUggJF5g= github.com/0chain/common v1.18.2/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw= github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= -github.com/0chain/gosdk v1.18.0-RC9 h1:vGkdZnt7uS+1OmgS1Qv/6wFPlZqUoJvqWuenf0tMffs= -github.com/0chain/gosdk v1.18.0-RC9/go.mod h1:q/zFTOMHU2hFGjFzIxCOZLonsmrSzYVP3ExCHHOmL6w= +github.com/0chain/gosdk v1.18.0-RC9.0.20241102174613-5e66d116bc76 h1:2QLTENTe36oXi8ZohLVRdxbXGcFaqLPMryKJpjmFmKU= +github.com/0chain/gosdk v1.18.0-RC9.0.20241102174613-5e66d116bc76/go.mod h1:q/zFTOMHU2hFGjFzIxCOZLonsmrSzYVP3ExCHHOmL6w= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=