Skip to content

Commit 2ccf8d1

Browse files
committed
fix: lint error
1 parent 15f1fbe commit 2ccf8d1

33 files changed

+215
-30
lines changed

crates/cli/commands/src/node.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ where
226226
let data_dir_for_monitor = data_dir.clone();
227227
let shutdown = ctx.task_executor.on_shutdown_signal().clone();
228228
let task_executor = ctx.task_executor.clone();
229-
229+
230230
ctx.task_executor.spawn_critical(
231231
"disk space monitor",
232232
Box::pin(disk_space_monitor_task(
@@ -253,18 +253,19 @@ impl<C: ChainSpecParser, Ext: clap::Args + fmt::Debug> NodeCommand<C, Ext> {
253253
}
254254
}
255255

256-
/// Disk space monitoring task that periodically checks disk space and triggers shutdown if below threshold.
256+
/// Disk space monitoring task that periodically checks disk space and triggers shutdown if below
257+
/// threshold.
257258
async fn disk_space_monitor_task(
258259
data_dir: reth_node_core::dirs::ChainPath<DataDirPath>,
259260
min_free_disk_mb: u64,
260261
mut shutdown: Shutdown,
261262
task_executor: TaskExecutor,
262263
) {
263264
use tokio::time::{interval, Duration as TokioDuration};
264-
265+
265266
let mut interval = interval(TokioDuration::from_secs(60)); // Check every minute
266267
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
267-
268+
268269
loop {
269270
tokio::select! {
270271
_ = interval.tick() => {

crates/node/core/src/args/datadir_args.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub struct DatadirArgs {
2828
)]
2929
pub static_files_path: Option<PathBuf>,
3030

31-
/// Minimum free disk space in MB, once reached triggers auto shut down (default = 0, disabled).
31+
/// Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
32+
/// disabled).
3233
#[arg(
3334
long = "datadir.min-free-disk",
3435
alias = "datadir.min_free_disk",
@@ -69,21 +70,15 @@ mod tests {
6970
#[test]
7071
fn test_parse_min_free_disk_flag() {
7172
// Test with hyphen format
72-
let args = CommandParser::<DatadirArgs>::parse_from([
73-
"reth",
74-
"--datadir.min-free-disk",
75-
"1000",
76-
])
77-
.args;
73+
let args =
74+
CommandParser::<DatadirArgs>::parse_from(["reth", "--datadir.min-free-disk", "1000"])
75+
.args;
7876
assert_eq!(args.min_free_disk, 1000);
7977

8078
// Test with underscore format (alias)
81-
let args = CommandParser::<DatadirArgs>::parse_from([
82-
"reth",
83-
"--datadir.min_free_disk",
84-
"500",
85-
])
86-
.args;
79+
let args =
80+
CommandParser::<DatadirArgs>::parse_from(["reth", "--datadir.min_free_disk", "500"])
81+
.args;
8782
assert_eq!(args.min_free_disk, 500);
8883

8984
// Test default value (0 = disabled)

crates/node/core/src/utils.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ where
9595
/// Returns the available space in MB, or None if the check fails.
9696
pub fn get_available_disk_space_mb(path: &Path) -> Option<u64> {
9797
use sysinfo::Disks;
98-
98+
9999
// Find the disk that contains the given path
100100
let path_canonical = match std::fs::canonicalize(path) {
101101
Ok(p) => p,
102102
Err(_) => return None,
103103
};
104-
104+
105105
let disks = Disks::new_with_refreshed_list();
106-
106+
107107
// Find the disk that contains the given path
108108
for disk in disks.iter() {
109109
let mount_point = disk.mount_point();
@@ -113,7 +113,7 @@ pub fn get_available_disk_space_mb(path: &Path) -> Option<u64> {
113113
return Some(available_bytes / (1024 * 1024));
114114
}
115115
}
116-
116+
117117
None
118118
}
119119

@@ -169,7 +169,7 @@ mod tests {
169169
// and returns a boolean value
170170
let temp_dir = std::env::temp_dir();
171171
let result = is_disk_space_low(&temp_dir, 1_000_000_000); // Very large threshold
172-
// Should return either true or false, but not panic
172+
// Should return either true or false, but not panic
173173
assert!(result == true || result == false);
174174
}
175175

@@ -213,20 +213,29 @@ mod tests {
213213
fn test_is_disk_space_low_threshold_comparison() {
214214
// Test that the function correctly compares available space with threshold
215215
let temp_dir = std::env::temp_dir();
216-
216+
217217
if let Some(available_mb) = get_available_disk_space_mb(&temp_dir) {
218-
// Test with a threshold smaller than available space (should pass - space is sufficient)
218+
// Test with a threshold smaller than available space (should pass - space is
219+
// sufficient)
219220
if available_mb > 0 {
220221
let result_small = is_disk_space_low(&temp_dir, available_mb.saturating_sub(1));
221-
assert!(!result_small, "Should pass (return false) when threshold is less than available space");
222+
assert!(
223+
!result_small,
224+
"Should pass (return false) when threshold is less than available space"
225+
);
222226
}
223-
224-
// Test with a threshold larger than available space (should fail - space is insufficient)
227+
228+
// Test with a threshold larger than available space (should fail - space is
229+
// insufficient)
225230
let result_large = is_disk_space_low(&temp_dir, available_mb.saturating_add(1));
226-
assert!(result_large, "Should fail (return true) when threshold is greater than available space");
227-
231+
assert!(
232+
result_large,
233+
"Should fail (return true) when threshold is greater than available space"
234+
);
235+
228236
// Test with threshold equal to available space (edge case)
229-
// When available == threshold, should trigger shutdown (return true) because "once reached" includes equality
237+
// When available == threshold, should trigger shutdown (return true) because "once
238+
// reached" includes equality
230239
let result_equal = is_disk_space_low(&temp_dir, available_mb);
231240
assert!(result_equal, "Should fail (return true) when threshold equals available space, as 'once reached' includes equality");
232241
}

docs/vocs/docs/pages/cli/op-reth/db.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Datadir:
4343
--datadir.static-files <PATH>
4444
The absolute path to store static files in.
4545
46+
--datadir.min-free-disk <MB>
47+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
48+
disabled).
49+
50+
[default: 0]
51+
4652
--config <FILE>
4753
The path to the configuration file to use
4854

docs/vocs/docs/pages/cli/op-reth/import-op.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Datadir:
2727
--datadir.static-files <PATH>
2828
The absolute path to store static files in.
2929
30+
--datadir.min-free-disk <MB>
31+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
32+
disabled).
33+
34+
[default: 0]
35+
3036
--config <FILE>
3137
The path to the configuration file to use
3238

docs/vocs/docs/pages/cli/op-reth/import-receipts-op.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Datadir:
2727
--datadir.static-files <PATH>
2828
The absolute path to store static files in.
2929
30+
--datadir.min-free-disk <MB>
31+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
32+
disabled).
33+
34+
[default: 0]
35+
3036
--config <FILE>
3137
The path to the configuration file to use
3238

docs/vocs/docs/pages/cli/op-reth/init-state.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Datadir:
2727
--datadir.static-files <PATH>
2828
The absolute path to store static files in.
2929
30+
--datadir.min-free-disk <MB>
31+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
32+
disabled).
33+
34+
[default: 0]
35+
3036
--config <FILE>
3137
The path to the configuration file to use
3238

docs/vocs/docs/pages/cli/op-reth/init.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Datadir:
2727
--datadir.static-files <PATH>
2828
The absolute path to store static files in.
2929
30+
--datadir.min-free-disk <MB>
31+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
32+
disabled).
33+
34+
[default: 0]
35+
3036
--config <FILE>
3137
The path to the configuration file to use
3238

docs/vocs/docs/pages/cli/op-reth/node.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ Datadir:
7171
--datadir.static-files <PATH>
7272
The absolute path to store static files in.
7373
74+
--datadir.min-free-disk <MB>
75+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
76+
disabled).
77+
78+
[default: 0]
79+
7480
Networking:
7581
-d, --disable-discovery
7682
Disable the discovery service

docs/vocs/docs/pages/cli/op-reth/p2p/body.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ Datadir:
243243
--datadir.static-files <PATH>
244244
The absolute path to store static files in.
245245
246+
--datadir.min-free-disk <MB>
247+
Minimum free disk space in MB, once reached triggers auto shut down (default = 0,
248+
disabled).
249+
250+
[default: 0]
251+
246252
--config <FILE>
247253
The path to the configuration file to use.
248254

0 commit comments

Comments
 (0)