AppendVec cleanup: remove dead code, rename non-idiomatic "new" function
This commit is contained in:
parent
1135ffd595
commit
65dd177601
|
@ -380,8 +380,8 @@ pub struct AccountStorageEntry {
|
|||
|
||||
impl AccountStorageEntry {
|
||||
pub fn new(path: &Path, slot: Slot, id: usize, file_size: u64) -> Self {
|
||||
let tail = AppendVec::new_relative_path(slot, id);
|
||||
let path = Path::new(path).join(&tail);
|
||||
let tail = AppendVec::file_name(slot, id);
|
||||
let path = Path::new(path).join(tail);
|
||||
let accounts = AppendVec::new(&path, true, file_size as usize);
|
||||
|
||||
Self {
|
||||
|
@ -543,10 +543,6 @@ impl AccountStorageEntry {
|
|||
count
|
||||
}
|
||||
|
||||
pub fn get_relative_path(&self) -> Option<PathBuf> {
|
||||
AppendVec::get_relative_path(self.accounts.get_path())
|
||||
}
|
||||
|
||||
pub fn get_path(&self) -> PathBuf {
|
||||
self.accounts.get_path()
|
||||
}
|
||||
|
|
|
@ -279,13 +279,8 @@ impl AppendVec {
|
|||
self.file_size
|
||||
}
|
||||
|
||||
// Get the file path relative to the top level accounts directory
|
||||
pub fn get_relative_path<P: AsRef<Path>>(append_vec_path: P) -> Option<PathBuf> {
|
||||
append_vec_path.as_ref().file_name().map(PathBuf::from)
|
||||
}
|
||||
|
||||
pub fn new_relative_path(slot: Slot, id: usize) -> PathBuf {
|
||||
PathBuf::from(&format!("{}.{}", slot, id))
|
||||
pub fn file_name(slot: Slot, id: usize) -> String {
|
||||
format!("{}.{}", slot, id)
|
||||
}
|
||||
|
||||
pub fn new_from_file<P: AsRef<Path>>(path: P, current_len: usize) -> io::Result<(Self, usize)> {
|
||||
|
@ -720,16 +715,6 @@ pub mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_path() {
|
||||
let relative_path = AppendVec::new_relative_path(0, 2);
|
||||
let full_path = Path::new("/tmp").join(&relative_path);
|
||||
assert_eq!(
|
||||
relative_path,
|
||||
AppendVec::get_relative_path(full_path).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_new_from_file_crafted_zero_lamport_account() {
|
||||
let file = get_append_vec_path("test_append");
|
||||
|
|
|
@ -313,8 +313,7 @@ where
|
|||
|
||||
// Move the corresponding AppendVec from the snapshot into the directory pointed
|
||||
// at by `local_dir`
|
||||
let append_vec_relative_path =
|
||||
AppendVec::new_relative_path(slot, storage_entry.id());
|
||||
let append_vec_relative_path = AppendVec::file_name(slot, storage_entry.id());
|
||||
let append_vec_abs_path = stream_append_vecs_path
|
||||
.as_ref()
|
||||
.join(&append_vec_relative_path);
|
||||
|
|
|
@ -27,7 +27,7 @@ fn copy_append_vecs<P: AsRef<Path>>(
|
|||
let storage_entries = accounts_db.get_snapshot_storages(Slot::max_value());
|
||||
for storage in storage_entries.iter().flatten() {
|
||||
let storage_path = storage.get_path();
|
||||
let output_path = output_dir.as_ref().join(AppendVec::new_relative_path(
|
||||
let output_path = output_dir.as_ref().join(AppendVec::file_name(
|
||||
storage.slot(),
|
||||
storage.append_vec_id(),
|
||||
));
|
||||
|
|
|
@ -271,11 +271,10 @@ pub fn archive_snapshot_package(snapshot_package: &AccountsPackage) -> Result<()
|
|||
for storage in snapshot_package.storages.iter().flatten() {
|
||||
storage.flush()?;
|
||||
let storage_path = storage.get_path();
|
||||
let output_path =
|
||||
staging_accounts_dir.join(crate::append_vec::AppendVec::new_relative_path(
|
||||
storage.slot(),
|
||||
storage.append_vec_id(),
|
||||
));
|
||||
let output_path = staging_accounts_dir.join(crate::append_vec::AppendVec::file_name(
|
||||
storage.slot(),
|
||||
storage.append_vec_id(),
|
||||
));
|
||||
|
||||
// `storage_path` - The file path where the AppendVec itself is located
|
||||
// `output_path` - The file path where the AppendVec will be placed in the staging directory.
|
||||
|
|
Loading…
Reference in New Issue