diff --git a/gossip/src/crds.rs b/gossip/src/crds.rs index eb8543a05da6e6..e665f0f615309f 100644 --- a/gossip/src/crds.rs +++ b/gossip/src/crds.rs @@ -401,9 +401,9 @@ impl Crds { cursor: &'a mut Cursor, ) -> impl Iterator { 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) }) } @@ -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, @@ -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 diff --git a/gossip/src/crds_data.rs b/gossip/src/crds_data.rs index 83d3f0b4292490..27a09bc28e6802 100644 --- a/gossip/src/crds_data.rs +++ b/gossip/src/crds_data.rs @@ -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))]