Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
refactor reconstruct_accountsdb_from_fields (#17987) (#18100)
Browse files Browse the repository at this point in the history
(cherry picked from commit ae82e4e)

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
  • Loading branch information
mergify[bot] and jeffwashington authored Jun 21, 2021
1 parent 71c49bc commit c676b7a
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use {
std::{
collections::{HashMap, HashSet},
io::{self, BufReader, BufWriter, Read, Write},
path::PathBuf,
path::{Path, PathBuf},
result::Result,
sync::{atomic::Ordering, Arc, RwLock},
},
Expand Down Expand Up @@ -287,6 +287,24 @@ where
Ok(bank)
}

fn reconstruct_single_storage<E>(
slot: &Slot,
append_vec_path: &Path,
storage_entry: &E,
new_slot_storage: &mut HashMap<AppendVecId, Arc<AccountStorageEntry>>,
) -> Result<(), Error>
where
E: SerializableStorage,
{
let (accounts, num_accounts) =
AppendVec::new_from_file(append_vec_path, storage_entry.current_len())?;
let u_storage_entry =
AccountStorageEntry::new_existing(*slot, storage_entry.id(), accounts, num_accounts);

new_slot_storage.insert(storage_entry.id(), Arc::new(u_storage_entry));
Ok(())
}

fn reconstruct_accountsdb_from_fields<E>(
accounts_db_fields: AccountsDbFields<E>,
account_paths: &[PathBuf],
Expand Down Expand Up @@ -333,16 +351,12 @@ where
)
})?;

let (accounts, num_accounts) =
AppendVec::new_from_file(append_vec_path, storage_entry.current_len())?;
let u_storage_entry = AccountStorageEntry::new_existing(
*slot,
storage_entry.id(),
accounts,
num_accounts,
);

new_slot_storage.insert(storage_entry.id(), Arc::new(u_storage_entry));
reconstruct_single_storage(
&slot,
append_vec_path,
storage_entry,
&mut new_slot_storage,
)?;
}
Ok((*slot, new_slot_storage))
})
Expand Down

0 comments on commit c676b7a

Please sign in to comment.