drive/util/grove_operations/grove_apply_partial_batch/
mod.rs

1use crate::drive::Drive;
2use crate::error::Error;
3use crate::query::GroveError;
4use crate::util::batch::GroveDbOpBatch;
5use dpp::version::drive_versions::DriveVersion;
6use grovedb::batch::{OpsByLevelPath, QualifiedGroveDbOp};
7use grovedb::TransactionArg;
8use grovedb_costs::OperationCost;
9
10impl Drive {
11    /// Applies the given groveDB operations batch.
12    ///
13    /// # Parameters
14    /// * `ops`: The batch of groveDB operations 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    /// * `add_on_operations`: A closure that takes in the operation cost and optional operation by level path
18    ///   and returns a result of groveDB operations or a grove error.
19    /// * `drive_version`: The drive version to select the correct function version to run.
20    ///
21    /// # Returns
22    /// * `Ok(())` if the operation was successful.
23    /// * `Err(DriveError::UnknownVersionMismatch)` if the drive version does not match known versions.
24    pub fn grove_apply_partial_batch(
25        &self,
26        ops: GroveDbOpBatch,
27        validate: bool,
28        transaction: TransactionArg,
29        add_on_operations: impl FnMut(
30            &OperationCost,
31            &Option<OpsByLevelPath>,
32        ) -> Result<Vec<QualifiedGroveDbOp>, GroveError>,
33        drive_version: &DriveVersion,
34    ) -> Result<(), Error> {
35        self.grove_apply_partial_batch_with_add_costs(
36            ops,
37            validate,
38            transaction,
39            add_on_operations,
40            &mut vec![],
41            drive_version,
42        )
43    }
44}