Push starting snapshot hashes in SnapshotGossipManager::new() (#31173)

This commit is contained in:
Brooks 2023-04-13 11:49:17 -04:00 committed by GitHub
parent fdecd0dcaa
commit e05957d8fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -57,11 +57,9 @@ impl SnapshotPackagerService {
SnapshotGossipManager::new( SnapshotGossipManager::new(
cluster_info, cluster_info,
max_full_snapshot_hashes, max_full_snapshot_hashes,
starting_snapshot_hashes,
) )
); );
if let Some(snapshot_gossip_manager) = snapshot_gossip_manager.as_mut() {
snapshot_gossip_manager.push_starting_snapshot_hashes(starting_snapshot_hashes);
}
loop { loop {
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {

View File

@ -19,28 +19,30 @@ pub struct SnapshotGossipManager {
} }
impl SnapshotGossipManager { impl SnapshotGossipManager {
/// Construct a new SnapshotGossipManager with empty snapshot hashes /// Construct a new SnapshotGossipManager and push any
/// starting snapshot hashes to the cluster via CRDS
#[must_use] #[must_use]
pub fn new(cluster_info: Arc<ClusterInfo>, max_full_snapshot_hashes: usize) -> Self { pub fn new(
SnapshotGossipManager { cluster_info: Arc<ClusterInfo>,
max_full_snapshot_hashes: usize,
starting_snapshot_hashes: Option<StartingSnapshotHashes>,
) -> Self {
let mut this = SnapshotGossipManager {
cluster_info, cluster_info,
latest_snapshot_hashes: None, latest_snapshot_hashes: None,
max_full_snapshot_hashes, max_full_snapshot_hashes,
legacy_full_snapshot_hashes: FullSnapshotHashes { legacy_full_snapshot_hashes: FullSnapshotHashes {
hashes: Vec::default(), hashes: Vec::default(),
}, },
};
if let Some(starting_snapshot_hashes) = starting_snapshot_hashes {
this.push_starting_snapshot_hashes(starting_snapshot_hashes);
} }
this
} }
/// Push any starting snapshot hashes to the cluster via CRDS /// Push starting snapshot hashes to the cluster via CRDS
pub fn push_starting_snapshot_hashes( fn push_starting_snapshot_hashes(&mut self, starting_snapshot_hashes: StartingSnapshotHashes) {
&mut self,
starting_snapshot_hashes: Option<StartingSnapshotHashes>,
) {
let Some(starting_snapshot_hashes) = starting_snapshot_hashes else {
return;
};
self.update_latest_full_snapshot_hash(starting_snapshot_hashes.full.hash); self.update_latest_full_snapshot_hash(starting_snapshot_hashes.full.hash);
if let Some(starting_incremental_snapshot_hash) = starting_snapshot_hashes.incremental { if let Some(starting_incremental_snapshot_hash) = starting_snapshot_hashes.incremental {
self.update_latest_incremental_snapshot_hash( self.update_latest_incremental_snapshot_hash(