@@ -200,6 +200,35 @@ impl<'db> MultiStateSyncSession<'db> {
200
200
unsafe { Pin :: into_inner_unchecked ( self ) } . transaction
201
201
}
202
202
203
+ /// Adds synchronization information for a subtree into the current synchronization session.
204
+ ///
205
+ /// This function interacts with a `GroveDb` database to open a Merk tree at the specified path,
206
+ /// calculate and verify its cryptographic hashes, and update the session state with the relevant
207
+ /// synchronization information. The function generates and returns the global chunk ID for
208
+ /// the subtree.
209
+ ///
210
+ /// # Parameters
211
+ /// - `self`: A pinned, boxed instance of the `MultiStateSyncSession`.
212
+ /// - `db`: A reference to the `GroveDb` instance.
213
+ /// - `path`: The path to the subtree as a `SubtreePath`.
214
+ /// - `hash`: The expected cryptographic hash of the subtree.
215
+ /// - `actual_hash`: An optional actual cryptographic hash to compare against the expected hash.
216
+ /// - `chunk_prefix`: A 32-byte prefix used for identifying chunks in the synchronization process.
217
+ /// - `grove_version`: The GroveDB version to use for processing.
218
+ ///
219
+ /// # Returns
220
+ /// - `Ok(Vec<u8>)`: On success, returns the encoded global chunk ID for the subtree.
221
+ /// - `Err(Error)`: If the Merk tree cannot be opened or synchronization information cannot be added.
222
+ ///
223
+ /// # Errors
224
+ /// This function returns an error if:
225
+ /// - The Merk tree at the specified path cannot be opened.
226
+ /// - Any synchronization-related operations fail.
227
+ /// - Internal errors occur during processing.
228
+ ///
229
+ /// # Safety
230
+ /// - This function uses unsafe code to create a reference to the transaction.
231
+ /// Ensure that the transaction is properly managed and the lifetime guarantees are respected.
203
232
pub fn add_subtree_sync_info < ' b , B : AsRef < [ u8 ] > > (
204
233
self : & mut Pin < Box < MultiStateSyncSession < ' db > > > ,
205
234
db : & ' db GroveDb ,
0 commit comments