drive/util/grove_operations/grove_delete/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use crate::fees::op::LowLevelDriveOperation;
7use dpp::version::drive_versions::DriveVersion;
8
9use grovedb::TransactionArg;
10use grovedb_path::SubtreePath;
11
12impl Drive {
13    /// Handles the deletion of an element in GroveDB at the specified path and key.
14    /// The operation cost is added to `drive_operations` for later processing.
15    ///
16    /// # Parameters
17    /// * `path`: The groveDB hierarchical authenticated structure path where the element is to be deleted.
18    /// * `key`: The key of the element to be deleted from the subtree.
19    /// * `transaction`: The groveDB transaction associated with this operation.
20    /// * `drive_operations`: A vector to collect the costs of operations for later computation.
21    /// * `platform_version`: The platform version to select the correct function version to run.
22    ///
23    /// # Returns
24    /// * `Ok(())` if the operation was successful.
25    /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
26    pub fn grove_delete<B: AsRef<[u8]>>(
27        &self,
28        path: SubtreePath<'_, B>,
29        key: &[u8],
30        transaction: TransactionArg,
31        drive_operations: &mut Vec<LowLevelDriveOperation>,
32        drive_version: &DriveVersion,
33    ) -> Result<(), Error> {
34        match drive_version.grove_methods.basic.grove_delete {
35            0 => self.grove_delete_v0(path, key, transaction, drive_operations, drive_version),
36            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
37                method: "grove_delete".to_string(),
38                known_versions: vec![0],
39                received: version,
40            })),
41        }
42    }
43}