Skip to content

Commit

Permalink
refactor: applied suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Jan 6, 2025
1 parent 29c49be commit da8d324
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
2 changes: 0 additions & 2 deletions grovedb/src/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ impl GroveDb {
));
}

println!(" starting:{:?}...", utils::path_to_string(&[]));

let root_prefix = [0u8; 32];

let mut session = self.start_syncing_session(app_hash);
Expand Down
24 changes: 3 additions & 21 deletions grovedb/src/replication/state_sync_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ struct SubtreeStateSyncInfo<'db> {
}

impl SubtreeStateSyncInfo<'_> {
pub fn get_current_path(&self) -> Vec<Vec<u8>> {
self.current_path.clone()
}

/// Applies a chunk using the given `SubtreeStateSyncInfo`.
///
/// # Parameters
Expand Down Expand Up @@ -382,7 +378,7 @@ impl<'db> MultiStateSyncSession<'db> {
return Ok(vec![]);
}

let completed_path = subtree_state_sync.get_current_path();
let completed_path = subtree_state_sync.current_path.clone();

// Subtree is finished. We can save it.
if subtree_state_sync.num_processed_chunks > 0 {
Expand All @@ -403,12 +399,8 @@ impl<'db> MultiStateSyncSession<'db> {

self.as_mut().processed_prefixes().insert(chunk_prefix);

println!(
" finished tree: {:?}",
path_to_string(completed_path.as_slice())
);
let new_subtrees_metadata =
self.discover_new_subtrees_metadata(db, completed_path.to_vec(), grove_version)?;
self.discover_new_subtrees_metadata(db, &completed_path, grove_version)?;

if let Ok(res) =
self.prepare_sync_state_sessions(db, new_subtrees_metadata, grove_version)
Expand Down Expand Up @@ -456,7 +448,7 @@ impl<'db> MultiStateSyncSession<'db> {
fn discover_new_subtrees_metadata(
self: &mut Pin<Box<MultiStateSyncSession<'db>>>,
db: &'db GroveDb,
path_vec: Vec<Vec<u8>>,
path_vec: &[Vec<u8>],
grove_version: &GroveVersion,
) -> Result<SubtreesMetadata, Error> {
let transaction_ref: &'db Transaction<'db> = unsafe {
Expand Down Expand Up @@ -500,12 +492,6 @@ impl<'db> MultiStateSyncSession<'db> {
let path: &[&[u8]] = &subtree_path;
let prefix = RocksDbStorage::build_prefix(path.as_ref().into()).unwrap();

println!(
" discovered {:?} prefix:{}",
path_to_string(&new_path),
hex::encode(prefix)
);

subtrees_metadata.data.insert(
prefix,
(new_path.to_vec(), actual_value_hash, elem_value_hash),
Expand Down Expand Up @@ -566,10 +552,6 @@ impl<'db> MultiStateSyncSession<'db> {
let subtree_path: Vec<&[u8]> =
current_path.iter().map(|vec| vec.as_slice()).collect();
let path: &[&[u8]] = &subtree_path;
println!(
" path:{:?} starting...",
path_to_string(&prefix_metadata.0)
);

let next_chunks_ids = self.add_subtree_sync_info(
db,
Expand Down

0 comments on commit da8d324

Please sign in to comment.