Skip to content

Commit

Permalink
excludes deprecated values from pull responses
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Nov 20, 2024
1 parent ed8ecbb commit a80c2ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
8 changes: 5 additions & 3 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ impl Crds {
cursor: &'a mut Cursor,
) -> impl Iterator<Item = &'a VersionedCrdsValue> {
let range = (Bound::Included(cursor.ordinal()), Bound::Unbounded);
self.entries.range(range).map(move |(ordinal, index)| {
cursor.consume(*ordinal);
self.table.index(*index)
self.entries.range(range).map(move |(&ordinal, &index)| {
cursor.consume(ordinal);
self.table.index(index)
})
}

Expand Down Expand Up @@ -463,6 +463,7 @@ impl Crds {

/// Returns all crds values which the first 'mask_bits'
/// of their hash value is equal to 'mask'.
/// Excludes deprecated values.
pub(crate) fn filter_bitmask(
&self,
mask: u64,
Expand All @@ -471,6 +472,7 @@ impl Crds {
self.shards
.find(mask, mask_bits)
.map(move |i| self.table.index(i))
.filter(|VersionedCrdsValue { value, .. }| !value.data().is_deprecated())
}

/// Update the timestamp's of all the labels that are associated with Pubkey
Expand Down
22 changes: 22 additions & 0 deletions gossip/src/crds_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,28 @@ impl CrdsData {
CrdsData::RestartHeaviestFork(fork) => fork.from,
}
}

#[inline]
#[must_use]
pub(crate) fn is_deprecated(&self) -> bool {
match self {
Self::LegacyContactInfo(_) => true,
Self::Vote(..) => false,
Self::LowestSlot(0, _) => false,
Self::LowestSlot(1.., _) => true,
Self::LegacySnapshotHashes(_) => true,
Self::AccountsHashes(_) => true,
Self::EpochSlots(..) => false,
Self::LegacyVersion(_) => true,
Self::Version(_) => true,
Self::NodeInstance(_) => true,
Self::DuplicateShred(..) => false,
Self::SnapshotHashes(_) => false,
Self::ContactInfo(_) => false,
Self::RestartLastVotedForkSlots(_) => false,
Self::RestartHeaviestFork(_) => false,
}
}
}

#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
Expand Down
12 changes: 10 additions & 2 deletions svm/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a80c2ea

Please sign in to comment.