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

Add {Vote, Tower}::last_voted_slot() #10734

Merged
merged 1 commit into from
Jun 23, 2020

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Jun 22, 2020

Problem

To address this, I need to reset self.last_vote when the snapshot is well descedent of the fork at which the previously-persisted Tower was at.

While reading code, I just realized various callers of Tower::last_vote() just needed last_slot in it.

Summary of Changes

Define appropriate getter: {Tower/Vote}::last_voted_slot().
Also this should remove the unneeded cloning of Vote while passing around.

This should contain no functional change.

Part of #10718

@ryoqun
Copy link
Member Author

ryoqun commented Jun 22, 2020

@carllin Could you take a look at this?

@codecov
Copy link

codecov bot commented Jun 22, 2020

Codecov Report

Merging #10734 into master will decrease coverage by 0.0%.
The diff coverage is 86.3%.

@@            Coverage Diff            @@
##           master   #10734     +/-   ##
=========================================
- Coverage    81.7%    81.7%   -0.1%     
=========================================
  Files         300      300             
  Lines       70509    70513      +4     
=========================================
- Hits        57660    57641     -19     
- Misses      12849    12872     +23     

@ryoqun ryoqun requested a review from carllin June 22, 2020 12:46
@@ -54,6 +54,10 @@ impl Vote {
timestamp: None,
}
}

pub fn last_voted_slot(&self) -> Option<Slot> {
self.slots.last().copied()
Copy link
Contributor

@carllin carllin Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to start being more mindful to do this over .cloned() when possible, good reminder!

@ryoqun ryoqun marked this pull request as ready for review June 23, 2020 01:33
@ryoqun ryoqun merged commit 0952b76 into solana-labs:master Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants