Skip to content

Commit a58094a

Browse files
committed
fix(client-lib): better requirements documentation
1 parent 30375d1 commit a58094a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mithril-client/src/utils/unexpected_downloaded_file_verifier.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
//!
77
//! Requirements:
88
//! * Existing extra files added by users should be kept
9+
//! * Directories may not exist: it can be run without any existing files or against an existing database
10+
//! * Should avoid blocking the main thread: watched directories can be quite large on mainnet and
11+
//! library users may be downloading archives in a multithreaded context
912
//! * Found offenders should be reported
13+
//! * Users should be able to easily distinct folders or directories from reported offenders
14+
//! * Reported list should be ordered so running twice with the same offenders yield the same message
15+
//! * Should take in particularities:
16+
//! * networks: immutables file numbers start at 1 on most network, but 0 on devnet
17+
//! * ancillaries' inclusion: it adds another immutables trio to the downloaded files
1018
//!
1119
use std::collections::HashSet;
1220
use std::ffi::OsString;
@@ -56,13 +64,12 @@ impl UnexpectedDownloadedFileVerifier {
5664
}
5765
}
5866

59-
/// Compute the expected state of the folder after download finish
67+
/// Compute the expected state of the folder after download completed
6068
pub async fn compute_expected_state_after_download(
6169
&self,
6270
) -> StdResult<ExpectedFilesAfterDownload> {
6371
let immutable_files_dir = self.target_cardano_db_dir.join(IMMUTABLE_DIR);
6472
let immutable_files_range_to_expect = self.immutable_files_range_to_expect.clone();
65-
// target databases can be quite large, avoid blocking the main thread
6673
let expected_files =
6774
tokio::task::spawn_blocking(move || -> StdResult<HashSet<OsString>> {
6875
let mut files: HashSet<OsString> = if immutable_files_dir.exists() {
@@ -132,7 +139,6 @@ impl ExpectedFilesAfterDownload {
132139
})
133140
.collect()
134141
} else {
135-
// The immutable dir can be missing if the download was interrupted
136142
Vec::new()
137143
};
138144
let mut removed_entries = Vec::new();
@@ -172,7 +178,6 @@ impl ExpectedFilesAfterDownload {
172178
if removed_entries.is_empty() {
173179
Ok(None)
174180
} else {
175-
// Sort removed entries to ensure consistent output when reporting to users
176181
removed_entries.sort();
177182

178183
slog::warn!(

0 commit comments

Comments
 (0)