Skip to content

Commit a8385d5

Browse files
authored
fix unreachable_pub in worker crate (#611)
* fix unreachable_pub in worker crate
1 parent 611f5ae commit a8385d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+215
-186
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ uninlined_format_args = "warn"
5151

5252
[workspace.lints.rust]
5353
unreachable_pub = "warn"
54-
manual_let_else = "warn"
54+
manual_let_else = "warn"

crates/worker/src/checks/hardware/gpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct GpuDevice {
2222
indices: Vec<u32>,
2323
}
2424

25-
pub fn detect_gpu() -> Vec<GpuSpecs> {
25+
pub(crate) fn detect_gpu() -> Vec<GpuSpecs> {
2626
Console::title("GPU Detection");
2727

2828
let gpu_devices = get_gpu_status();

crates/worker/src/checks/hardware/hardware_check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use std::sync::Arc;
1414
use sysinfo::{self, System};
1515
use tokio::sync::RwLock;
1616

17-
pub struct HardwareChecker {
17+
pub(crate) struct HardwareChecker {
1818
sys: System,
1919
issues: Arc<RwLock<IssueReport>>,
2020
}
2121

2222
impl HardwareChecker {
23-
pub fn new(issues: Option<Arc<RwLock<IssueReport>>>) -> Self {
23+
pub(crate) fn new(issues: Option<Arc<RwLock<IssueReport>>>) -> Self {
2424
let mut sys = System::new_all();
2525

2626
sys.refresh_all();
@@ -30,7 +30,7 @@ impl HardwareChecker {
3030
}
3131
}
3232

33-
pub async fn check_hardware(
33+
pub(crate) async fn check_hardware(
3434
&mut self,
3535
node_config: Node,
3636
storage_path_override: Option<String>,

crates/worker/src/checks/hardware/interconnect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use rand::RngCore;
22
use reqwest::Client;
33
use std::time::Instant;
44

5-
pub struct InterconnectCheck;
5+
pub(crate) struct InterconnectCheck;
66

77
impl InterconnectCheck {
8-
pub async fn check_speeds() -> Result<(f64, f64), Box<dyn std::error::Error>> {
8+
pub(crate) async fn check_speeds() -> Result<(f64, f64), Box<dyn std::error::Error>> {
99
let client = Client::new();
1010

1111
// Download test: Request a 10 MB file using the query parameter.

crates/worker/src/checks/hardware/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use sysinfo::System;
33

44
const BYTES_TO_GB: u64 = 1024 * 1024 * 1024;
55

6-
pub fn get_memory_info(sys: &System) -> (u64, u64) {
6+
pub(crate) fn get_memory_info(sys: &System) -> (u64, u64) {
77
let total_memory = sys.total_memory();
88
let free_memory = sys.available_memory();
99
(total_memory, free_memory)
1010
}
1111

12-
pub fn convert_to_mb(memory: u64) -> u64 {
12+
pub(crate) fn convert_to_mb(memory: u64) -> u64 {
1313
memory / (1024 * 1024)
1414
}
1515

16-
pub fn print_memory_info(total_memory: u64, free_memory: u64) {
16+
pub(crate) fn print_memory_info(total_memory: u64, free_memory: u64) {
1717
let total_gb = (total_memory + BYTES_TO_GB / 2) / BYTES_TO_GB;
1818
let free_gb = (free_memory + BYTES_TO_GB / 2) / BYTES_TO_GB;
1919
Console::title("Memory Information:");
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pub mod gpu;
2-
pub mod hardware_check;
3-
pub mod interconnect;
4-
pub mod memory;
5-
pub mod storage;
6-
pub mod storage_path;
7-
pub use hardware_check::HardwareChecker;
1+
pub(crate) mod gpu;
2+
pub(crate) mod hardware_check;
3+
pub(crate) mod interconnect;
4+
pub(crate) mod memory;
5+
pub(crate) mod storage;
6+
pub(crate) mod storage_path;
7+
pub(crate) use hardware_check::HardwareChecker;

crates/worker/src/checks/hardware/storage.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ use std::env;
66
use std::ffi::CString;
77
#[cfg(target_os = "linux")]
88
use std::fs;
9-
pub const BYTES_TO_GB: f64 = 1024.0 * 1024.0 * 1024.0;
10-
pub const APP_DIR_NAME: &str = "prime-worker";
9+
pub(crate) const BYTES_TO_GB: f64 = 1024.0 * 1024.0 * 1024.0;
10+
pub(crate) const APP_DIR_NAME: &str = "prime-worker";
1111

1212
#[derive(Clone)]
13-
pub struct MountPoint {
13+
pub(crate) struct MountPoint {
1414
pub path: String,
1515
pub available_space: u64,
1616
}
1717

1818
#[cfg(unix)]
19-
pub fn get_storage_info() -> Result<(f64, f64), std::io::Error> {
19+
pub(crate) fn get_storage_info() -> Result<(f64, f64), std::io::Error> {
2020
let mut stat: libc::statvfs = unsafe { std::mem::zeroed() };
2121

2222
// Use current directory instead of hardcoded "."
@@ -68,7 +68,7 @@ pub fn get_storage_info() -> Result<(f64, f64), std::io::Error> {
6868
))
6969
}
7070
#[cfg(target_os = "linux")]
71-
pub fn find_largest_storage() -> Option<MountPoint> {
71+
pub(crate) fn find_largest_storage() -> Option<MountPoint> {
7272
const VALID_FS: [&str; 4] = ["ext4", "xfs", "btrfs", "zfs"];
7373
const MIN_SPACE: u64 = 1_000_000_000; // 1GB minimum
7474

@@ -221,7 +221,7 @@ pub fn find_largest_storage() -> Option<MountPoint> {
221221
}
222222

223223
#[cfg(target_os = "linux")]
224-
pub fn get_available_space(path: &str) -> Option<u64> {
224+
pub(crate) fn get_available_space(path: &str) -> Option<u64> {
225225
let mut stats: statvfs_t = unsafe { std::mem::zeroed() };
226226
if let Ok(path_c) = CString::new(path) {
227227
if unsafe { statvfs(path_c.as_ptr(), &mut stats) } == 0 {
@@ -238,7 +238,7 @@ pub fn get_available_space(_path: &str) -> Option<u64> {
238238
}
239239

240240
#[allow(dead_code)]
241-
pub fn print_storage_info() {
241+
pub(crate) fn print_storage_info() {
242242
match get_storage_info() {
243243
Ok((total, free)) => {
244244
Console::title("Storage Information:");

crates/worker/src/checks/hardware/storage_path.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use log::info;
88
use std::sync::Arc;
99
use tokio::sync::RwLock;
1010

11-
pub struct StoragePathDetector {
11+
pub(crate) struct StoragePathDetector {
1212
issues: Arc<RwLock<IssueReport>>,
1313
}
1414

1515
impl StoragePathDetector {
16-
pub fn new(issues: Arc<RwLock<IssueReport>>) -> Self {
16+
pub(crate) fn new(issues: Arc<RwLock<IssueReport>>) -> Self {
1717
Self { issues }
1818
}
1919

20-
pub async fn detect_storage_path(
20+
pub(crate) async fn detect_storage_path(
2121
&self,
2222
storage_path_override: Option<String>,
2323
) -> Result<(String, Option<u64>), Box<dyn std::error::Error>> {

crates/worker/src/checks/issue.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::fmt;
33
use std::sync::{Arc, RwLock};
44

55
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6-
pub enum Severity {
6+
pub(crate) enum Severity {
77
Warning,
88
Error,
99
}
1010

1111
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12-
pub enum IssueType {
12+
pub(crate) enum IssueType {
1313
NoGpu, // GPU required for compute
1414
DockerNotInstalled, // Docker required for containers
1515
ContainerToolkitNotInstalled, // Container toolkit required for GPU
@@ -22,7 +22,7 @@ pub enum IssueType {
2222
}
2323

2424
impl IssueType {
25-
pub const fn severity(&self) -> Severity {
25+
pub(crate) const fn severity(&self) -> Severity {
2626
match self {
2727
Self::NetworkConnectivityIssue
2828
| Self::InsufficientCpu
@@ -38,24 +38,24 @@ impl IssueType {
3838
}
3939

4040
#[derive(Debug, Clone)]
41-
pub struct Issue {
41+
pub(crate) struct Issue {
4242
issue_type: IssueType,
4343
message: String,
4444
}
4545

4646
impl Issue {
47-
pub fn new(issue_type: IssueType, message: impl Into<String>) -> Self {
47+
pub(crate) fn new(issue_type: IssueType, message: impl Into<String>) -> Self {
4848
Self {
4949
issue_type,
5050
message: message.into(),
5151
}
5252
}
5353

54-
pub const fn severity(&self) -> Severity {
54+
pub(crate) const fn severity(&self) -> Severity {
5555
self.issue_type.severity()
5656
}
5757

58-
pub fn print(&self) {
58+
pub(crate) fn print(&self) {
5959
match self.severity() {
6060
Severity::Error => Console::user_error(&format!("{self}")),
6161
Severity::Warning => Console::warning(&format!("{self}")),
@@ -70,22 +70,22 @@ impl fmt::Display for Issue {
7070
}
7171

7272
#[derive(Debug, Default, Clone)]
73-
pub struct IssueReport {
73+
pub(crate) struct IssueReport {
7474
issues: Arc<RwLock<Vec<Issue>>>,
7575
}
7676

7777
impl IssueReport {
78-
pub fn new() -> Self {
78+
pub(crate) fn new() -> Self {
7979
Self::default()
8080
}
8181

82-
pub fn add_issue(&self, issue_type: IssueType, message: impl Into<String>) {
82+
pub(crate) fn add_issue(&self, issue_type: IssueType, message: impl Into<String>) {
8383
if let Ok(mut issues) = self.issues.write() {
8484
issues.push(Issue::new(issue_type, message));
8585
}
8686
}
8787

88-
pub fn print_issues(&self) {
88+
pub(crate) fn print_issues(&self) {
8989
if let Ok(issues) = self.issues.read() {
9090
if issues.is_empty() {
9191
Console::success("No issues found");
@@ -104,7 +104,7 @@ impl IssueReport {
104104
}
105105
}
106106

107-
pub fn has_critical_issues(&self) -> bool {
107+
pub(crate) fn has_critical_issues(&self) -> bool {
108108
if let Ok(issues) = self.issues.read() {
109109
return issues
110110
.iter()

crates/worker/src/checks/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub mod hardware;
2-
pub mod issue;
3-
pub mod software;
4-
pub mod stun;
1+
pub(crate) mod hardware;
2+
pub(crate) mod issue;
3+
pub(crate) mod software;
4+
pub(crate) mod stun;

0 commit comments

Comments
 (0)