drive/util/grove_operations/grove_apply_operation/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use dpp::version::drive_versions::DriveVersion;
7use grovedb::batch::QualifiedGroveDbOp;
8use grovedb::TransactionArg;
9
10impl Drive {
11    /// Applies the given groveDB operation.
12    ///
13    /// # Parameters
14    /// * `operation`: The groveDB operation to apply.
15    /// * `validate`: Specifies whether to validate that insertions do not override existing entries.
16    /// * `transaction`: The groveDB transaction associated with this operation.
17    /// * `drive_version`: The drive version to select the correct function version to run.
18    ///
19    /// # Returns
20    /// * `Ok(())` if the operation was successful.
21    /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions.
22    pub fn grove_apply_operation(
23        &self,
24        operation: QualifiedGroveDbOp,
25        validate: bool,
26        transaction: TransactionArg,
27        drive_version: &DriveVersion,
28    ) -> Result<(), Error> {
29        match drive_version.grove_methods.apply.grove_apply_operation {
30            0 => self.grove_apply_operation_v0(operation, validate, transaction, drive_version),
31            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
32                method: "grove_apply_operation".to_string(),
33                known_versions: vec![0],
34                received: version,
35            })),
36        }
37    }
38}