diff --git a/grovedb/src/replication.rs b/grovedb/src/replication.rs index d147340b..d40c5aa4 100644 --- a/grovedb/src/replication.rs +++ b/grovedb/src/replication.rs @@ -22,9 +22,15 @@ impl GroveDb { MultiStateSyncSession::new(self.start_transaction(), app_hash) } - pub fn commit_session(&self, session: Pin>) { - // we do not care about the cost - let _ = self.commit_transaction(session.into_transaction()); + pub fn commit_session(&self, session: Pin>) -> Result<(), Error> { + match self.commit_transaction(session.into_transaction()).value { + Ok(_) => Ok(()), + Err(e) => { + // Log the error or handle it as needed + eprintln!("Failed to commit session: {:?}", e); + Err(e) + } + } } // Fetch a chunk by global chunk id (should be called by ABCI when @@ -168,12 +174,12 @@ impl GroveDb { /// should be called by ABCI when OfferSnapshot method is called. /// Returns the first set of global chunk ids that can be fetched from /// sources and a new sync session. - pub fn start_snapshot_syncing<'db>( - &'db self, + pub fn start_snapshot_syncing( + &self, app_hash: CryptoHash, version: u16, grove_version: &GroveVersion, - ) -> Result>>, Error> { + ) -> Result>, Error> { check_grovedb_v0!( "start_snapshot_syncing", grove_version @@ -211,7 +217,7 @@ impl GroveDb { pub fn util_path_to_string(path: &[Vec]) -> Vec { let mut subtree_path_str: Vec = vec![]; for subtree in path { - let string = std::str::from_utf8(&subtree).unwrap_or_else(|_| ""); + let string = std::str::from_utf8(subtree).unwrap_or(""); subtree_path_str.push(string.to_string()); } subtree_path_str diff --git a/grovedb/src/replication/state_sync_session.rs b/grovedb/src/replication/state_sync_session.rs index 2a26fe56..6eca688b 100644 --- a/grovedb/src/replication/state_sync_session.rs +++ b/grovedb/src/replication/state_sync_session.rs @@ -260,7 +260,7 @@ impl<'db> MultiStateSyncSession<'db> { next_chunk_ids.push(util_create_global_chunk_id( chunk_prefix, subtree_state_sync.root_key.clone(), - subtree_state_sync.is_sum_tree.clone(), + subtree_state_sync.is_sum_tree, local_chunk_id.clone(), )); } @@ -403,9 +403,9 @@ impl<'db> MultiStateSyncSession<'db> { let next_chunks_ids = self.add_subtree_sync_info( db, path.into(), - elem_value_hash.clone(), - Some(actual_value_hash.clone()), - prefix.clone(), + *elem_value_hash, + Some(*actual_value_hash), + *prefix, grove_version, )?; diff --git a/tutorials/src/bin/replication.rs b/tutorials/src/bin/replication.rs index 96cb867f..74374c33 100644 --- a/tutorials/src/bin/replication.rs +++ b/tutorials/src/bin/replication.rs @@ -263,7 +263,7 @@ fn sync_db_demo( println!("num_chunks: {}", num_chunks); if session.is_sync_completed() { - target_db.commit_session(session); + target_db.commit_session(session).expect("failed to commit session"); } let elapsed = start_time.elapsed(); println!("state_synced in {:.2?}", elapsed);