Skip to content

Commit

Permalink
refactor: rename LocalUploader to LocalSnapshotUploader
Browse files Browse the repository at this point in the history
  • Loading branch information
dlachaume committed Jan 2, 2025
1 parent b248b4f commit fa7a3c6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use mithril_common::{
CardanoNetwork, StdResult,
};

use crate::{snapshotter::OngoingSnapshot, FileUploader, LocalUploader, Snapshotter};
use crate::{snapshotter::OngoingSnapshot, FileUploader, LocalSnapshotUploader, Snapshotter};

/// The [AncillaryFileUploader] trait allows identifying uploaders that return locations for ancillary archive files.
#[cfg_attr(test, mockall::automock)]
Expand All @@ -25,7 +25,7 @@ pub trait AncillaryFileUploader: Send + Sync {
}

#[async_trait]
impl AncillaryFileUploader for LocalUploader {
impl AncillaryFileUploader for LocalSnapshotUploader {
async fn upload(&self, filepath: &Path) -> StdResult<AncillaryLocation> {
let uri = FileUploader::upload(self, filepath).await?.into();

Expand Down
6 changes: 3 additions & 3 deletions mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ use crate::{
tools::{CExplorerSignerRetriever, GenesisToolsDependency, SignersImporter},
AggregatorConfig, AggregatorRunner, AggregatorRuntime, CompressedArchiveSnapshotter,
Configuration, DependencyContainer, DumbSnapshotter, DumbUploader, EpochSettingsStorer,
LocalUploader, MetricsService, MithrilSignerRegisterer, MultiSigner, MultiSignerImpl,
LocalSnapshotUploader, MetricsService, MithrilSignerRegisterer, MultiSigner, MultiSignerImpl,
SingleSignatureAuthenticator, SnapshotUploaderType, Snapshotter,
SnapshotterCompressionAlgorithm, VerificationKeyStorer,
};
Expand Down Expand Up @@ -471,7 +471,7 @@ impl DependenciesBuilder {
logger.clone(),
)))
}
SnapshotUploaderType::Local => Ok(Arc::new(LocalUploader::new(
SnapshotUploaderType::Local => Ok(Arc::new(LocalSnapshotUploader::new(
format!(
"{}{}",
self.configuration.get_server_url(),
Expand Down Expand Up @@ -1206,7 +1206,7 @@ impl DependenciesBuilder {
error: Some(e.into()),
}
})?;
let local_uploader = LocalUploader::new(
let local_uploader = LocalSnapshotUploader::new(
format!(
"{}{}",
self.configuration.get_server_url(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ use mithril_common::StdResult;
use crate::file_uploaders::{FileUploader, FileUri};
use crate::tools;

/// LocalUploader is a file uploader working using local files
pub struct LocalUploader {
// TODO: This specific local uploader will be removed.
// It's only used by the legacy snapshot that uploads the entire Cardano database.
/// LocalSnapshotUploader is a file uploader working using local files
pub struct LocalSnapshotUploader {
/// File server URL prefix
server_url_prefix: String,

Expand All @@ -20,11 +22,11 @@ pub struct LocalUploader {
logger: Logger,
}

impl LocalUploader {
/// LocalUploader factory
impl LocalSnapshotUploader {
/// LocalSnapshotUploader factory
pub(crate) fn new(server_url_prefix: String, target_location: &Path, logger: Logger) -> Self {
let logger = logger.new_with_component_name::<Self>();
debug!(logger, "New LocalUploader created"; "server_url_prefix" => &server_url_prefix);
debug!(logger, "New LocalSnapshotUploader created"; "server_url_prefix" => &server_url_prefix);
Self {
server_url_prefix,
target_location: target_location.to_path_buf(),
Expand All @@ -34,7 +36,7 @@ impl LocalUploader {
}

#[async_trait]
impl FileUploader for LocalUploader {
impl FileUploader for LocalSnapshotUploader {
async fn upload(&self, filepath: &Path) -> StdResult<FileUri> {
let archive_name = filepath.file_name().unwrap().to_str().unwrap();
let target_path = &self.target_location.join(archive_name);
Expand Down Expand Up @@ -66,7 +68,7 @@ mod tests {
use crate::file_uploaders::{FileUploader, FileUri};
use crate::test_tools::TestLogger;

use super::LocalUploader;
use super::LocalSnapshotUploader;

fn create_fake_archive(dir: &Path, digest: &str) -> PathBuf {
let file_path = dir.join(format!("test.{digest}.tar.gz"));
Expand All @@ -92,7 +94,8 @@ mod tests {
);

let url_prefix = "http://test.com:8080/base-root".to_string();
let uploader = LocalUploader::new(url_prefix, target_dir.path(), TestLogger::stdout());
let uploader =
LocalSnapshotUploader::new(url_prefix, target_dir.path(), TestLogger::stdout());
let location = uploader
.upload(&archive)
.await
Expand All @@ -107,7 +110,7 @@ mod tests {
let target_dir = tempdir().unwrap();
let digest = "41e27b9ed5a32531b95b2b7ff3c0757591a06a337efaf19a524a998e348028e7";
let archive = create_fake_archive(source_dir.path(), digest);
let uploader = LocalUploader::new(
let uploader = LocalSnapshotUploader::new(
"http://test.com:8080/base-root/".to_string(),
target_dir.path(),
TestLogger::stdout(),
Expand All @@ -126,7 +129,7 @@ mod tests {
let digest = "41e27b9ed5a32531b95b2b7ff3c0757591a06a337efaf19a524a998e348028e7";
create_fake_archive(source_dir.path(), digest);
let target_dir = tempdir().unwrap();
let uploader = LocalUploader::new(
let uploader = LocalSnapshotUploader::new(
"http://test.com:8080/base-root/".to_string(),
target_dir.path(),
TestLogger::stdout(),
Expand Down
4 changes: 2 additions & 2 deletions mithril-aggregator/src/file_uploaders/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod dumb_uploader;
mod gcp_uploader;
mod interface;
mod local_uploader;
mod local_snapshot_uploader;

pub use dumb_uploader::*;
pub use gcp_uploader::GcpUploader;
pub use interface::FileUploader;
pub use interface::FileUri;
pub use local_uploader::LocalUploader;
pub use local_snapshot_uploader::LocalSnapshotUploader;

#[cfg(test)]
pub use interface::MockFileUploader;
2 changes: 1 addition & 1 deletion mithril-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use crate::configuration::{
pub use crate::multi_signer::{MultiSigner, MultiSignerImpl};
pub use commands::{CommandType, MainOpts};
pub use dependency_injection::DependencyContainer;
pub use file_uploaders::{DumbUploader, FileUploader, LocalUploader};
pub use file_uploaders::{DumbUploader, FileUploader, LocalSnapshotUploader};
pub use message_adapters::{FromRegisterSignerAdapter, ToCertificatePendingMessageAdapter};
pub use metrics::*;
pub use runtime::{
Expand Down

0 comments on commit fa7a3c6

Please sign in to comment.