drive/util/grove_operations/grove_has_raw/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use crate::fees::op::LowLevelDriveOperation;
7use crate::util::grove_operations::DirectQueryType;
8
9use dpp::version::drive_versions::DriveVersion;
10
11use grovedb::TransactionArg;
12use grovedb_path::SubtreePath;
13
14impl Drive {
15    /// Checks whether an element exists in groveDB at the specified path and key.
16    /// The operation's cost is then appended to `drive_operations` for later processing.
17    ///
18    /// # Parameters
19    /// * `path`: The groveDB hierarchical authenticated structure path where the element resides.
20    /// * `key`: The key where the element resides within the subtree.
21    /// * `query_type`: The type of query to perform, either `StatelessDirectQuery` or `StatefulDirectQuery`.
22    /// * `transaction`: The groveDB transaction associated with this operation.
23    /// * `drive_operations`: A vector to collect the costs of operations for later computation.
24    /// * `platform_version`: The platform version to select the correct function version to run.
25    ///
26    /// # Returns
27    /// * `Ok(bool)` if the operation was successful, returning `true` if the element exists and `false` otherwise.
28    /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
29    pub fn grove_has_raw<B: AsRef<[u8]>>(
30        &self,
31        path: SubtreePath<'_, B>,
32        key: &[u8],
33        query_type: DirectQueryType,
34        transaction: TransactionArg,
35        drive_operations: &mut Vec<LowLevelDriveOperation>,
36        drive_version: &DriveVersion,
37    ) -> Result<bool, Error> {
38        match drive_version.grove_methods.basic.grove_has_raw {
39            0 => self.grove_has_raw_v0(
40                path,
41                key,
42                query_type,
43                transaction,
44                drive_operations,
45                drive_version,
46            ),
47            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
48                method: "grove_has_raw".to_string(),
49                known_versions: vec![0],
50                received: version,
51            })),
52        }
53    }
54}