code cleanup, storage_size() was Option<u64>, now Result<u64> (#7424)
This commit is contained in:
parent
dbb8267b09
commit
83218c479a
|
@ -66,7 +66,7 @@ impl LedgerCleanupService {
|
||||||
|
|
||||||
let disk_utilization_post = blocktree.storage_size();
|
let disk_utilization_post = blocktree.storage_size();
|
||||||
|
|
||||||
if let (Some(disk_utilization_pre), Some(disk_utilization_post)) =
|
if let (Ok(disk_utilization_pre), Ok(disk_utilization_post)) =
|
||||||
(disk_utilization_pre, disk_utilization_post)
|
(disk_utilization_pre, disk_utilization_post)
|
||||||
{
|
{
|
||||||
datapoint_debug!(
|
datapoint_debug!(
|
||||||
|
|
|
@ -1499,9 +1499,7 @@ impl Blocktree {
|
||||||
self.last_root()
|
self.last_root()
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the approximate size in bytes of the storage directory, or `None` if an error occurs
|
pub fn storage_size(&self) -> Result<u64> {
|
||||||
// while reading the directory (directory not found, file deleted, etc)
|
|
||||||
pub fn storage_size(&self) -> Option<u64> {
|
|
||||||
self.db.storage_size()
|
self.db.storage_size()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::blocktree_meta;
|
use crate::blocktree_meta;
|
||||||
use bincode::{deserialize, serialize};
|
use bincode::{deserialize, serialize};
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use fs_extra::dir::get_size;
|
use fs_extra;
|
||||||
use log::*;
|
use log::*;
|
||||||
pub use rocksdb::Direction as IteratorDirection;
|
pub use rocksdb::Direction as IteratorDirection;
|
||||||
use rocksdb::{
|
use rocksdb::{
|
||||||
|
@ -43,6 +43,7 @@ pub enum BlocktreeError {
|
||||||
SlotNotRooted,
|
SlotNotRooted,
|
||||||
IO(#[from] std::io::Error),
|
IO(#[from] std::io::Error),
|
||||||
Serialize(#[from] Box<bincode::ErrorKind>),
|
Serialize(#[from] Box<bincode::ErrorKind>),
|
||||||
|
FsExtraError(#[from] fs_extra::error::Error),
|
||||||
}
|
}
|
||||||
pub(crate) type Result<T> = std::result::Result<T, BlocktreeError>;
|
pub(crate) type Result<T> = std::result::Result<T, BlocktreeError>;
|
||||||
|
|
||||||
|
@ -580,10 +581,8 @@ impl Database {
|
||||||
self.backend.write(batch.write_batch)
|
self.backend.write(batch.write_batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the approximate size in bytes of the storage directory, or `None` if an error occurs
|
pub fn storage_size(&self) -> Result<u64> {
|
||||||
// while reading the directory (directory not found, file deleted, etc)
|
Ok(fs_extra::dir::get_size(&self.path)?)
|
||||||
pub fn storage_size(&self) -> Option<u64> {
|
|
||||||
get_size(&self.path).ok()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue