Only gossip snapshot hashes for full snapshots (#20271)

This commit is contained in:
Brooks Prumo 2021-09-27 19:29:08 -05:00 committed by GitHub
parent af309c126c
commit 3ea6a01254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,9 @@
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_runtime::{
snapshot_archive_info::SnapshotArchiveInfoGetter, snapshot_config::SnapshotConfig,
snapshot_package::PendingSnapshotPackage, snapshot_utils,
snapshot_archive_info::SnapshotArchiveInfoGetter,
snapshot_config::SnapshotConfig,
snapshot_package::{PendingSnapshotPackage, SnapshotType},
snapshot_utils,
};
use solana_sdk::{clock::Slot, hash::Hash};
use std::{
@ -58,11 +60,15 @@ impl SnapshotPackagerService {
)
.expect("failed to archive snapshot package");
hashes.push((snapshot_package.slot(), *snapshot_package.hash()));
while hashes.len() > MAX_SNAPSHOT_HASHES {
hashes.remove(0);
// NOTE: For backwards compatibility with version <=1.7, only _full_ snapshots
// can have their hashes pushed out to the cluster.
if snapshot_package.snapshot_type == SnapshotType::FullSnapshot {
hashes.push((snapshot_package.slot(), *snapshot_package.hash()));
while hashes.len() > MAX_SNAPSHOT_HASHES {
hashes.remove(0);
}
cluster_info.push_snapshot_hashes(hashes.clone());
}
cluster_info.push_snapshot_hashes(hashes.clone());
}
})
.unwrap();