Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

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

Merged
ryoqun merged 1 commit intosolana-labs:masterfrom
ryoqun:add-last-voted-slot
Jun 23, 2020
Merged

Add {Vote, Tower}::last_voted_slot()#10734
ryoqun merged 1 commit intosolana-labs:masterfrom
ryoqun:add-last-voted-slot

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor Author

ryoqun commented Jun 22, 2020

@carllin Could you take a look at this?

@codecov
Copy link
Copy Markdown

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
}

pub fn last_voted_slot(&self) -> Option<Slot> {
self.slots.last().copied()
Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants