Skip to content

Commit

Permalink
Merge pull request #139 from stader-labs/1.4.2-hotfix
Browse files Browse the repository at this point in the history
1.4.2 hotfix
  • Loading branch information
batphonghan authored Nov 2, 2023
2 parents afba869 + 26d65e4 commit f5f9e3e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions stader-cli/service/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ func migrate(c *cli.Context) ([]ConfigUpgrader, error) {
},
}

cfg, err := loadConfig(c)
staderClient, err := stader.NewClientFromCtx(c)
if err != nil {
return nil, fmt.Errorf("error NewClientFromCtx: %w", err)
}

cfg, _, err := staderClient.LoadConfig()
if err != nil {
return nil, fmt.Errorf("error loading user settings: %w", err)
}

// cfg nill or version empty in case fresh install
if cfg == nil || len(cfg.Version) == 0 {
fmt.Printf("Can not found config %+v\n", cfg)
return nil, nil
}

Expand Down Expand Up @@ -108,8 +114,8 @@ func upgradeFuncV140(c *cli.Context) error {
if err != nil {
return fmt.Errorf("error NewClientFromCtx: %w", err)
}
err = staderClient.UpdateGuardianConfiguration(guardian)

err = staderClient.UpdateGuardianConfiguration(guardian)
if err != nil {
return fmt.Errorf("error NewClientFromCtx: %w", err)
}
Expand All @@ -128,7 +134,7 @@ func upgradeFuncV142(c *cli.Context) error {
return fmt.Errorf("error loading user settings: %w", err)
}

cycleMerkleRewardFile := cfg.StaderNode.GetSpRewardCyclePath(RefreshingCycle, true)
cycleMerkleRewardFile := cfg.StaderNode.GetSpRewardCyclePath(RefreshingCycle, false)

expandedCycleMerkleRewardFile, err := homedir.Expand(cycleMerkleRewardFile)
if err != nil {
Expand All @@ -141,6 +147,8 @@ func upgradeFuncV142(c *cli.Context) error {
if err = os.Remove(expandedCycleMerkleRewardFile); err != nil {
return fmt.Errorf("error Remove old cycle 5: %w", err)
}

fmt.Printf("Success remove %+v \n", cycleMerkleRewardFile)
}

// Download new one
Expand Down

0 comments on commit f5f9e3e

Please sign in to comment.