change blocktree*::storage_size() to return Option<u64> to handle live fs changes (#7401)

This commit is contained in:
Sunny Gleason 2019-12-10 19:12:49 -05:00 committed by GitHub
parent 12d471e2da
commit 06415de8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

View File

@ -66,16 +66,20 @@ impl LedgerCleanupService {
let disk_utilization_post = blocktree.storage_size();
datapoint_debug!(
"ledger_disk_utilization",
("disk_utilization_pre", disk_utilization_pre as i64, i64),
("disk_utilization_post", disk_utilization_post as i64, i64),
(
"disk_utilization_delta",
(disk_utilization_pre as i64 - disk_utilization_post as i64),
i64
)
);
if let (Some(disk_utilization_pre), Some(disk_utilization_post)) =
(disk_utilization_pre, disk_utilization_post)
{
datapoint_debug!(
"ledger_disk_utilization",
("disk_utilization_pre", disk_utilization_pre as i64, i64),
("disk_utilization_post", disk_utilization_post as i64, i64),
(
"disk_utilization_delta",
(disk_utilization_pre as i64 - disk_utilization_post as i64),
i64
)
);
}
Ok(())
}

View File

@ -1493,7 +1493,7 @@ impl Blocktree {
self.last_root()
}
pub fn storage_size(&self) -> u64 {
pub fn storage_size(&self) -> Option<u64> {
self.db.storage_size()
}
}

View File

@ -580,8 +580,8 @@ impl Database {
self.backend.write(batch.write_batch)
}
pub fn storage_size(&self) -> u64 {
get_size(&self.path).expect("failure while reading ledger directory size")
pub fn storage_size(&self) -> Option<u64> {
get_size(&self.path).ok()
}
}