Only gossip packaged snapshots

This commit is contained in:
Michael Vines 2020-03-02 12:38:16 -07:00
parent 8ef8c9094a
commit 42c5c59800
1 changed files with 9 additions and 9 deletions

View File

@ -35,17 +35,16 @@ impl SnapshotPackagerService {
match snapshot_package_receiver.recv_timeout(Duration::from_secs(1)) { match snapshot_package_receiver.recv_timeout(Duration::from_secs(1)) {
Ok(mut snapshot_package) => { Ok(mut snapshot_package) => {
hashes.push((snapshot_package.root, snapshot_package.hash));
// Only package the latest // Only package the latest
while let Ok(new_snapshot_package) = while let Ok(new_snapshot_package) =
snapshot_package_receiver.try_recv() snapshot_package_receiver.try_recv()
{ {
snapshot_package = new_snapshot_package; snapshot_package = new_snapshot_package;
hashes.push((snapshot_package.root, snapshot_package.hash));
} }
if let Err(err) = archive_snapshot_package(&snapshot_package) { if let Err(err) = archive_snapshot_package(&snapshot_package) {
warn!("Failed to create snapshot archive: {}", err); warn!("Failed to create snapshot archive: {}", err);
} } else {
hashes.push((snapshot_package.root, snapshot_package.hash));
while hashes.len() > MAX_SNAPSHOT_HASHES { while hashes.len() > MAX_SNAPSHOT_HASHES {
hashes.remove(0); hashes.remove(0);
} }
@ -54,6 +53,7 @@ impl SnapshotPackagerService {
.unwrap() .unwrap()
.push_snapshot_hashes(hashes.clone()); .push_snapshot_hashes(hashes.clone());
} }
}
Err(RecvTimeoutError::Disconnected) => break, Err(RecvTimeoutError::Disconnected) => break,
Err(RecvTimeoutError::Timeout) => (), Err(RecvTimeoutError::Timeout) => (),
} }