Skip to content

Commit

Permalink
Update blobber version reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Nov 2, 2024
1 parent f7b5382 commit 47f9825
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions cmd/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")

}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 47f9825

Please sign in to comment.