-
Notifications
You must be signed in to change notification settings - Fork 523
Add compatibility mode for listpartkeys goal command. #3207
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
Add compatibility mode for listpartkeys goal command. #3207
Conversation
| // legacyListParticipationKeysCommand prints key information in the same | ||
| // format as earlier versions of goal. Some users are using this information | ||
| // in scripts and need some extra time to migrate to the REST API. | ||
| func legacyListParticipationKeysCommand() { | ||
| dataDir := ensureSingleDataDir() | ||
|
|
||
| client := ensureGoalClient(dataDir, libgoal.DynamicClient) | ||
| parts, err := client.ListParticipationKeyFiles() | ||
| if err != nil { | ||
| reportErrorf(errorRequestFail, err) | ||
| } | ||
|
|
||
| var filenames []string | ||
| for fn := range parts { | ||
| filenames = append(filenames, fn) | ||
| } | ||
| sort.Strings(filenames) | ||
|
|
||
| rowFormat := "%-10s\t%-80s\t%-60s\t%12s\t%12s\t%12s\n" | ||
| fmt.Printf(rowFormat, "Registered", "Filename", "Parent address", "First round", "Last round", "First key") | ||
| for _, fn := range filenames { | ||
| onlineInfoStr := "unknown" | ||
| onlineAccountInfo, err := client.AccountInformation(parts[fn].Address().GetUserAddress()) | ||
| if err == nil { | ||
| votingBytes := parts[fn].Voting.OneTimeSignatureVerifier | ||
| vrfBytes := parts[fn].VRF.PK | ||
| if onlineAccountInfo.Participation != nil && | ||
| (string(onlineAccountInfo.Participation.ParticipationPK) == string(votingBytes[:])) && | ||
| (string(onlineAccountInfo.Participation.VRFPK) == string(vrfBytes[:])) && | ||
| (onlineAccountInfo.Participation.VoteFirst == uint64(parts[fn].FirstValid)) && | ||
| (onlineAccountInfo.Participation.VoteLast == uint64(parts[fn].LastValid)) && | ||
| (onlineAccountInfo.Participation.VoteKeyDilution == parts[fn].KeyDilution) { | ||
| onlineInfoStr = "yes" | ||
| } else { | ||
| onlineInfoStr = "no" | ||
| } | ||
| } | ||
| // it's okay to proceed without algod info | ||
| first, last := parts[fn].ValidInterval() | ||
| fmt.Printf(rowFormat, onlineInfoStr, fn, parts[fn].Address().GetUserAddress(), | ||
| fmt.Sprintf("%d", first), | ||
| fmt.Sprintf("%d", last), | ||
| fmt.Sprintf("%d.%d", parts[fn].Voting.FirstBatch, parts[fn].Voting.FirstOffset)) | ||
| } | ||
| } |
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.
The only difference between this function and the previous version of the cobra command is to rename ListParticipationKey to ListParticipationKeyFiles.
tsachiherman
left a comment
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.
looks great.
Summary
Add a simple compatibility mode to give a buffer for migration to new REST APIs.
Test Plan
Manual testing: