Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4.2 hotfix #139

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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