Skip to content

Commit ba98002

Browse files
committed
feat: unpack digests after download in client
1 parent b083c06 commit ba98002

File tree

2 files changed

+50
-7
lines changed
  • mithril-aggregator/src/artifact_builder/cardano_database_artifacts
  • mithril-client/src/cardano_database_client

2 files changed

+50
-7
lines changed

mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,12 @@ impl DigestArtifactBuilder {
228228
async fn upload_digest_file(&self, digest_filepath: &Path) -> StdResult<Vec<DigestLocation>> {
229229
let mut locations = Vec::<DigestLocation>::new();
230230
for uploader in &self.uploaders {
231-
let result = uploader.upload(digest_filepath, None).await;
231+
let result = uploader
232+
.upload(
233+
digest_filepath,
234+
Some(self.digest_snapshotter.compression_algorithm),
235+
)
236+
.await;
232237
match result {
233238
Ok(location) => {
234239
locations.push(location);
@@ -618,7 +623,7 @@ mod tests {
618623

619624
digest_file_uploader
620625
.expect_upload()
621-
.with(eq(archive_path.clone()), eq(None))
626+
.with(eq(archive_path.clone()), eq(Some(compression_algorithm)))
622627
.times(1)
623628
.return_once(move |_, _| {
624629
assert!(

mithril-client/src/cardano_database_client/proving.rs

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ impl InternalArtifactProver {
9292
locations_sorted.sort();
9393
for location in locations_sorted {
9494
let download_id = MithrilEvent::new_cardano_database_download_id();
95-
let file_downloader = match &location {
96-
DigestLocation::CloudStorage { .. } | DigestLocation::Aggregator { .. } => {
97-
self.http_file_downloader.clone()
98-
}
95+
let (file_downloader, compression_algorithm) = match &location {
96+
DigestLocation::CloudStorage {
97+
uri: _,
98+
compression_algorithm,
99+
} => (self.http_file_downloader.clone(), *compression_algorithm),
100+
DigestLocation::Aggregator { .. } => (self.http_file_downloader.clone(), None),
99101
// Note: unknown locations should have been filtered out by `sanitized_locations`
100102
DigestLocation::Unknown => unreachable!(),
101103
};
@@ -105,7 +107,7 @@ impl InternalArtifactProver {
105107
&file_downloader_uri,
106108
digests_locations.size_uncompressed,
107109
digests_file_target_dir,
108-
None,
110+
compression_algorithm,
109111
DownloadEvent::Digest {
110112
download_id: download_id.clone(),
111113
},
@@ -339,6 +341,8 @@ mod tests {
339341

340342
mod download_unpack_digest_file {
341343

344+
use mithril_common::entities::CompressionAlgorithm;
345+
342346
use crate::file_downloader::MockFileDownloader;
343347

344348
use super::*;
@@ -466,6 +470,40 @@ mod tests {
466470
.await
467471
.unwrap();
468472
}
473+
474+
#[tokio::test]
475+
async fn should_call_download_with_compression_algorithm() {
476+
let target_dir = Path::new(".");
477+
let artifact_prover = InternalArtifactProver::new(
478+
Arc::new(
479+
MockFileDownloaderBuilder::default()
480+
.with_compression(Some(CompressionAlgorithm::Gzip))
481+
.with_times(1)
482+
.with_success()
483+
.build(),
484+
),
485+
test_utils::test_logger(),
486+
);
487+
488+
artifact_prover
489+
.download_unpack_digest_file(
490+
&DigestsMessagePart {
491+
locations: vec![
492+
DigestLocation::CloudStorage {
493+
uri: "http://whatever-1/digests.tar.gz".to_string(),
494+
compression_algorithm: Some(CompressionAlgorithm::Gzip),
495+
},
496+
DigestLocation::Aggregator {
497+
uri: "http://whatever-2/digest".to_string(),
498+
},
499+
],
500+
size_uncompressed: 0,
501+
},
502+
target_dir,
503+
)
504+
.await
505+
.unwrap();
506+
}
469507
}
470508

471509
mod read_digest_file {

0 commit comments

Comments
 (0)