drive/util/grove_operations/batch_insert_empty_tree/
mod.rs

1mod v0;
2
3use crate::util::object_size_info::DriveKeyInfo;
4use crate::util::storage_flags::StorageFlags;
5
6use crate::drive::Drive;
7use crate::error::drive::DriveError;
8use crate::error::Error;
9use crate::fees::op::LowLevelDriveOperation;
10use dpp::version::drive_versions::DriveVersion;
11
12impl Drive {
13    /// Pushes an "insert empty tree" operation to `drive_operations`.
14    ///
15    /// # Parameters
16    /// * `path`: The path to insert an empty tree.
17    /// * `key_info`: The key information of the document.
18    /// * `storage_flags`: Storage options for the operation.
19    /// * `drive_operations`: The vector containing low-level drive operations.
20    /// * `drive_version`: The drive version to select the correct function version to run.
21    ///
22    /// # Returns
23    /// * `Ok(())` if the operation was successful.
24    /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions.
25    pub fn batch_insert_empty_tree<'a, 'c, P>(
26        &'a self,
27        path: P,
28        key_info: DriveKeyInfo<'c>,
29        storage_flags: Option<&StorageFlags>,
30        drive_operations: &mut Vec<LowLevelDriveOperation>,
31        drive_version: &DriveVersion,
32    ) -> Result<(), Error>
33    where
34        P: IntoIterator<Item = &'c [u8]>,
35        <P as IntoIterator>::IntoIter: ExactSizeIterator + DoubleEndedIterator + Clone,
36    {
37        match drive_version.grove_methods.batch.batch_insert_empty_tree {
38            0 => self.batch_insert_empty_tree_v0(path, key_info, storage_flags, drive_operations),
39            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
40                method: "batch_insert_empty_tree".to_string(),
41                known_versions: vec![0],
42                received: version,
43            })),
44        }
45    }
46}