Add get_incremental_snapshot_hash_for_node() to gossip (#20394)
This commit is contained in:
parent
069586c171
commit
57592e463e
|
@ -23,8 +23,8 @@ use {
|
||||||
crds_gossip_error::CrdsGossipError,
|
crds_gossip_error::CrdsGossipError,
|
||||||
crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
|
crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
|
||||||
crds_value::{
|
crds_value::{
|
||||||
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance,
|
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, IncrementalSnapshotHashes,
|
||||||
SnapshotHashes, Version, Vote, MAX_WALLCLOCK,
|
LowestSlot, NodeInstance, SnapshotHashes, Version, Vote, MAX_WALLCLOCK,
|
||||||
},
|
},
|
||||||
epoch_slots::EpochSlots,
|
epoch_slots::EpochSlots,
|
||||||
gossip_error::GossipError,
|
gossip_error::GossipError,
|
||||||
|
@ -1116,6 +1116,18 @@ impl ClusterInfo {
|
||||||
Some(map(hashes))
|
Some(map(hashes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_incremental_snapshot_hashes_for_node(
|
||||||
|
&self,
|
||||||
|
pubkey: &Pubkey,
|
||||||
|
) -> Option<IncrementalSnapshotHashes> {
|
||||||
|
self.gossip
|
||||||
|
.crds
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.get::<&IncrementalSnapshotHashes>(*pubkey)
|
||||||
|
.cloned()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns epoch-slots inserted since the given cursor.
|
/// Returns epoch-slots inserted since the given cursor.
|
||||||
/// Excludes entries from nodes with unkown or different shred version.
|
/// Excludes entries from nodes with unkown or different shred version.
|
||||||
pub fn get_epoch_slots(&self, cursor: &mut Cursor) -> Vec<EpochSlots> {
|
pub fn get_epoch_slots(&self, cursor: &mut Cursor) -> Vec<EpochSlots> {
|
||||||
|
|
|
@ -3,7 +3,8 @@ use {
|
||||||
contact_info::ContactInfo,
|
contact_info::ContactInfo,
|
||||||
crds::VersionedCrdsValue,
|
crds::VersionedCrdsValue,
|
||||||
crds_value::{
|
crds_value::{
|
||||||
CrdsData, CrdsValue, CrdsValueLabel, LegacyVersion, LowestSlot, SnapshotHashes, Version,
|
CrdsData, CrdsValue, CrdsValueLabel, IncrementalSnapshotHashes, LegacyVersion,
|
||||||
|
LowestSlot, SnapshotHashes, Version,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
indexmap::IndexMap,
|
indexmap::IndexMap,
|
||||||
|
@ -56,6 +57,11 @@ impl_crds_entry!(ContactInfo, CrdsData::ContactInfo(node), node);
|
||||||
impl_crds_entry!(LegacyVersion, CrdsData::LegacyVersion(version), version);
|
impl_crds_entry!(LegacyVersion, CrdsData::LegacyVersion(version), version);
|
||||||
impl_crds_entry!(LowestSlot, CrdsData::LowestSlot(_, slot), slot);
|
impl_crds_entry!(LowestSlot, CrdsData::LowestSlot(_, slot), slot);
|
||||||
impl_crds_entry!(Version, CrdsData::Version(version), version);
|
impl_crds_entry!(Version, CrdsData::Version(version), version);
|
||||||
|
impl_crds_entry!(
|
||||||
|
IncrementalSnapshotHashes,
|
||||||
|
CrdsData::IncrementalSnapshotHashes(incremental_snapshot_hashes),
|
||||||
|
incremental_snapshot_hashes
|
||||||
|
);
|
||||||
|
|
||||||
impl<'a, 'b> CrdsEntry<'a, 'b> for &'a SnapshotHashes {
|
impl<'a, 'b> CrdsEntry<'a, 'b> for &'a SnapshotHashes {
|
||||||
type Key = Pubkey;
|
type Key = Pubkey;
|
||||||
|
@ -114,6 +120,9 @@ mod tests {
|
||||||
CrdsData::SnapshotHashes(hash) => {
|
CrdsData::SnapshotHashes(hash) => {
|
||||||
assert_eq!(crds.get::<&SnapshotHashes>(key), Some(hash))
|
assert_eq!(crds.get::<&SnapshotHashes>(key), Some(hash))
|
||||||
}
|
}
|
||||||
|
CrdsData::IncrementalSnapshotHashes(hash) => {
|
||||||
|
assert_eq!(crds.get::<&IncrementalSnapshotHashes>(key), Some(hash))
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,10 +209,10 @@ impl SnapshotHashes {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
||||||
pub struct IncrementalSnapshotHashes {
|
pub struct IncrementalSnapshotHashes {
|
||||||
from: Pubkey,
|
pub(crate) from: Pubkey,
|
||||||
base: (Slot, Hash),
|
pub(crate) base: (Slot, Hash),
|
||||||
hashes: Vec<(Slot, Hash)>,
|
pub(crate) hashes: Vec<(Slot, Hash)>,
|
||||||
wallclock: u64,
|
pub(crate) wallclock: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sanitize for IncrementalSnapshotHashes {
|
impl Sanitize for IncrementalSnapshotHashes {
|
||||||
|
|
Loading…
Reference in New Issue