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
feat: update x/upgrade keeper.DumpUpgradeInfoToDisk to support Plan.Info #10532
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,23 +325,35 @@ func (k Keeper) IsSkipHeight(height int64) bool { | |
return k.skipUpgradeHeights[height] | ||
} | ||
|
||
// DumpUpgradeInfoToDisk writes upgrade information to UpgradeInfoFileName. | ||
// DumpUpgradeInfoToDisk writes upgrade information to UpgradeInfoFileName. The function | ||
// doesn't save the `Plan.Info` data, hence it won't support auto download functionality | ||
// by cosmvisor. | ||
// NOTE: this function will be update in the next release. | ||
func (k Keeper) DumpUpgradeInfoToDisk(height int64, name string) error { | ||
return k.DumpUpgradeInfoWithInfoToDisk(height, name, "") | ||
} | ||
|
||
// Deprecated: DumpUpgradeInfoWithInfoToDisk writes upgrade information to UpgradeInfoFileName. | ||
// `info` should be provided and contain Plan.Info data in order to support | ||
// auto download functionality by cosmovisor and other tools using upgarde-info.json | ||
// (GetUpgradeInfoPath()) file. | ||
func (k Keeper) DumpUpgradeInfoWithInfoToDisk(height int64, name string, info string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hate this kind of names.... but couldn't find better one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like it either lol. What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole thing is a Plan (name, height, info...). |
||
upgradeInfoFilePath, err := k.GetUpgradeInfoPath() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
upgradeInfo := store.UpgradeInfo{ | ||
upgradeInfo := upgradeInfo{ | ||
Name: name, | ||
Height: height, | ||
Info: info, | ||
} | ||
info, err := json.Marshal(upgradeInfo) | ||
bz, err := json.Marshal(upgradeInfo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return ioutil.WriteFile(upgradeInfoFilePath, info, 0600) | ||
return ioutil.WriteFile(upgradeInfoFilePath, bz, 0600) | ||
} | ||
|
||
// GetUpgradeInfoPath returns the upgrade info file path | ||
|
@@ -388,3 +400,13 @@ func (k Keeper) ReadUpgradeInfoFromDisk() (store.UpgradeInfo, error) { | |
|
||
return upgradeInfo, nil | ||
} | ||
|
||
// upgradeInfo is stripped types.Plan structure used to dump upgrade plan data. | ||
type upgradeInfo struct { | ||
// Name has types.Plan.Name value | ||
Name string `json:"name,omitempty"` | ||
// Height has types.Plan.Height value | ||
Height int64 `json:"height,omitempty"` | ||
// Height has types.Plan.Height value | ||
Info string `json:"info,omitempty"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a new function which is deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok