This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Show more detailed vote history in shorter format #13374
Merged
+47
−21
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -582,6 +582,45 @@ pub struct CliEpochReward { | |
| pub apr: f64, | ||
| } | ||
|
|
||
| fn show_votes_and_credits( | ||
| f: &mut fmt::Formatter, | ||
| votes: &[CliLockout], | ||
| epoch_voting_history: &[CliEpochVotingHistory], | ||
| ) -> fmt::Result { | ||
| if votes.is_empty() { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| writeln!(f, "Recent Votes:")?; | ||
| for vote in votes { | ||
| writeln!(f, "- slot: {}", vote.slot)?; | ||
| writeln!(f, " confirmation count: {}", vote.confirmation_count)?; | ||
| } | ||
| writeln!(f, "Epoch Voting History:")?; | ||
| writeln!( | ||
| f, | ||
| "* missed credits include slots unavailable to vote on due to delinquent leaders", | ||
| )?; | ||
| for entry in epoch_voting_history { | ||
| writeln!( | ||
| f, // tame fmt so that this will be folded like following | ||
| "- epoch: {}", | ||
| entry.epoch | ||
| )?; | ||
| writeln!( | ||
| f, | ||
| " credits range: [{}..{})", | ||
| entry.prev_credits, entry.credits | ||
| )?; | ||
| writeln!( | ||
| f, | ||
| " credits/slots: {}/{}", | ||
| entry.credits_earned, entry.slots_in_epoch | ||
|
Contributor
Author
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. Imply that |
||
| )?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn show_epoch_rewards( | ||
| f: &mut fmt::Formatter, | ||
| epoch_rewards: &Option<Vec<CliEpochReward>>, | ||
|
|
@@ -1009,24 +1048,7 @@ impl fmt::Display for CliVoteAccount { | |
| unix_timestamp_to_string(self.recent_timestamp.timestamp), | ||
| self.recent_timestamp.slot | ||
| )?; | ||
| if !self.votes.is_empty() { | ||
| writeln!(f, "Recent Votes:")?; | ||
| for vote in &self.votes { | ||
| writeln!( | ||
| f, | ||
| "- slot: {}\n confirmation count: {}", | ||
| vote.slot, vote.confirmation_count | ||
| )?; | ||
| } | ||
| writeln!(f, "Epoch Voting History:")?; | ||
| for epoch_info in &self.epoch_voting_history { | ||
| writeln!( | ||
| f, | ||
| "- epoch: {}\n slots in epoch: {}\n credits earned: {}", | ||
| epoch_info.epoch, epoch_info.slots_in_epoch, epoch_info.credits_earned, | ||
| )?; | ||
| } | ||
| } | ||
| show_votes_and_credits(f, &self.votes, &self.epoch_voting_history)?; | ||
| show_epoch_rewards(f, &self.epoch_rewards)?; | ||
| Ok(()) | ||
| } | ||
|
|
@@ -1065,6 +1087,8 @@ pub struct CliEpochVotingHistory { | |
| pub epoch: Epoch, | ||
| pub slots_in_epoch: u64, | ||
| pub credits_earned: u64, | ||
| pub credits: u64, | ||
| pub prev_credits: u64, | ||
| } | ||
|
|
||
| #[derive(Serialize, Deserialize)] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Especially, I needed this info.