-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Rename CRDS SnapshotHash to SnapshotHashes #20421
Merged
brooksprumo
merged 2 commits into
solana-labs:master
from
brooksprumo:crds-snapshot-hashes
Oct 5, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 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 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -84,8 +84,8 @@ pub enum CrdsData { | |
ContactInfo(ContactInfo), | ||
Vote(VoteIndex, Vote), | ||
LowestSlot(/*DEPRECATED:*/ u8, LowestSlot), | ||
SnapshotHashes(SnapshotHash), | ||
AccountsHashes(SnapshotHash), | ||
SnapshotHashes(SnapshotHashes), | ||
AccountsHashes(SnapshotHashes), | ||
EpochSlots(EpochSlotsIndex, EpochSlots), | ||
LegacyVersion(LegacyVersion), | ||
Version(Version), | ||
|
@@ -147,8 +147,8 @@ impl CrdsData { | |
match kind { | ||
0 => CrdsData::ContactInfo(ContactInfo::new_rand(rng, pubkey)), | ||
1 => CrdsData::LowestSlot(rng.gen(), LowestSlot::new_rand(rng, pubkey)), | ||
2 => CrdsData::SnapshotHashes(SnapshotHash::new_rand(rng, pubkey)), | ||
3 => CrdsData::AccountsHashes(SnapshotHash::new_rand(rng, pubkey)), | ||
2 => CrdsData::SnapshotHashes(SnapshotHashes::new_rand(rng, pubkey)), | ||
3 => CrdsData::AccountsHashes(SnapshotHashes::new_rand(rng, pubkey)), | ||
4 => CrdsData::Version(Version::new_rand(rng, pubkey)), | ||
5 => CrdsData::Vote(rng.gen_range(0, MAX_VOTES), Vote::new_rand(rng, pubkey)), | ||
_ => CrdsData::EpochSlots( | ||
|
@@ -160,13 +160,13 @@ impl CrdsData { | |
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)] | ||
pub struct SnapshotHash { | ||
pub struct SnapshotHashes { | ||
pub from: Pubkey, | ||
pub hashes: Vec<(Slot, Hash)>, | ||
pub wallclock: u64, | ||
} | ||
Comment on lines
+163
to
167
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. And here's the actual struct. The singular "SnapshotHash" was a little strange to me, since there's a vector of hashes inside... |
||
|
||
impl Sanitize for SnapshotHash { | ||
impl Sanitize for SnapshotHashes { | ||
fn sanitize(&self) -> Result<(), SanitizeError> { | ||
sanitize_wallclock(self.wallclock)?; | ||
for (slot, _) in &self.hashes { | ||
|
@@ -178,7 +178,7 @@ impl Sanitize for SnapshotHash { | |
} | ||
} | ||
|
||
impl SnapshotHash { | ||
impl SnapshotHashes { | ||
pub fn new(from: Pubkey, hashes: Vec<(Slot, Hash)>) -> Self { | ||
Self { | ||
from, | ||
|
@@ -187,7 +187,7 @@ impl SnapshotHash { | |
} | ||
} | ||
|
||
/// New random SnapshotHash for tests and benchmarks. | ||
/// New random SnapshotHashes for tests and benchmarks. | ||
pub(crate) fn new_rand<R: Rng>(rng: &mut R, pubkey: Option<Pubkey>) -> Self { | ||
let num_hashes = rng.gen_range(0, MAX_SNAPSHOT_HASHES) + 1; | ||
let hashes = std::iter::repeat_with(|| { | ||
|
@@ -475,7 +475,7 @@ impl fmt::Display for CrdsValueLabel { | |
CrdsValueLabel::ContactInfo(_) => write!(f, "ContactInfo({})", self.pubkey()), | ||
CrdsValueLabel::Vote(ix, _) => write!(f, "Vote({}, {})", ix, self.pubkey()), | ||
CrdsValueLabel::LowestSlot(_) => write!(f, "LowestSlot({})", self.pubkey()), | ||
CrdsValueLabel::SnapshotHashes(_) => write!(f, "SnapshotHash({})", self.pubkey()), | ||
CrdsValueLabel::SnapshotHashes(_) => write!(f, "SnapshotHashes({})", self.pubkey()), | ||
CrdsValueLabel::EpochSlots(ix, _) => write!(f, "EpochSlots({}, {})", ix, self.pubkey()), | ||
CrdsValueLabel::AccountsHashes(_) => write!(f, "AccountsHashes({})", self.pubkey()), | ||
CrdsValueLabel::LegacyVersion(_) => write!(f, "LegacyVersion({})", self.pubkey()), | ||
|
@@ -584,7 +584,7 @@ impl CrdsValue { | |
} | ||
} | ||
|
||
pub(crate) fn accounts_hash(&self) -> Option<&SnapshotHash> { | ||
pub(crate) fn accounts_hash(&self) -> Option<&SnapshotHashes> { | ||
match &self.data { | ||
CrdsData::AccountsHashes(slots) => Some(slots), | ||
_ => None, | ||
|
This file contains 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.
In this PR comment (#20374 (comment)), @behzadnouri mentioned that following the naming scheme of (old)
SnapshotHashes
wasn't the right call. So here's the update to make this better.