-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: bump GroveDB dependency (#2196)
Co-authored-by: Quantum Explorer <[email protected]>
- Loading branch information
1 parent
6230b53
commit 37b5ea4
Showing
5 changed files
with
109 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 53 additions & 54 deletions
107
...drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,53 @@ | ||
//todo: uncomment once version 2.1 of GroveDB is released. | ||
// mod v0; | ||
// | ||
// use crate::drive::Drive; | ||
// use crate::error::drive::DriveError; | ||
// use crate::error::Error; | ||
// use crate::fees::op::LowLevelDriveOperation; | ||
// use dpp::version::drive_versions::DriveVersion; | ||
// use grovedb::{Element, TransactionArg}; | ||
// use grovedb_path::SubtreePath; | ||
// | ||
// impl Drive { | ||
// /// Inserts an element into groveDB only if the specified path and key do not exist. | ||
// /// This operation costs are then stored in `drive_operations`. | ||
// /// | ||
// /// # Parameters | ||
// /// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted. | ||
// /// * `key`: The key where the new element should be inserted in the subtree. | ||
// /// * `element`: The element to be inserted. | ||
// /// * `transaction`: The groveDB transaction associated with this operation. | ||
// /// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case, | ||
// /// it collects the cost of this insert operation if the path and key did not exist. | ||
// /// * `platform_version`: The platform version to select the correct function version to run. | ||
// /// | ||
// /// # Returns | ||
// /// * `Ok(true)` if the insertion was successful. | ||
// /// * `Ok(false)` if the path and key already existed. | ||
// /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions. | ||
// pub fn grove_insert_if_not_exists_return_existing_element<B: AsRef<[u8]>>( | ||
// &self, | ||
// path: SubtreePath<'_, B>, | ||
// key: &[u8], | ||
// element: Element, | ||
// transaction: TransactionArg, | ||
// drive_operations: Option<&mut Vec<LowLevelDriveOperation>>, | ||
// drive_version: &DriveVersion, | ||
// ) -> Result<Option<Element>, Error> { | ||
// match drive_version.grove_methods.basic.grove_insert_if_not_exists { | ||
// 0 => self.grove_insert_if_not_exists_return_existing_element_v0( | ||
// path, | ||
// key, | ||
// element, | ||
// transaction, | ||
// drive_operations, | ||
// drive_version, | ||
// ), | ||
// version => Err(Error::Drive(DriveError::UnknownVersionMismatch { | ||
// method: "grove_insert_if_not_exists_return_existing_element".to_string(), | ||
// known_versions: vec![0], | ||
// received: version, | ||
// })), | ||
// } | ||
// } | ||
// } | ||
mod v0; | ||
|
||
use crate::drive::Drive; | ||
use crate::error::drive::DriveError; | ||
use crate::error::Error; | ||
use crate::fees::op::LowLevelDriveOperation; | ||
use dpp::version::drive_versions::DriveVersion; | ||
use grovedb::{Element, TransactionArg}; | ||
use grovedb_path::SubtreePath; | ||
|
||
impl Drive { | ||
/// Inserts an element into groveDB only if the specified path and key do not exist. | ||
/// This operation costs are then stored in `drive_operations`. | ||
/// | ||
/// # Parameters | ||
/// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted. | ||
/// * `key`: The key where the new element should be inserted in the subtree. | ||
/// * `element`: The element to be inserted. | ||
/// * `transaction`: The groveDB transaction associated with this operation. | ||
/// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case, | ||
/// it collects the cost of this insert operation if the path and key did not exist. | ||
/// * `platform_version`: The platform version to select the correct function version to run. | ||
/// | ||
/// # Returns | ||
/// * `Ok(true)` if the insertion was successful. | ||
/// * `Ok(false)` if the path and key already existed. | ||
/// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions. | ||
pub fn grove_insert_if_not_exists_return_existing_element<B: AsRef<[u8]>>( | ||
&self, | ||
path: SubtreePath<'_, B>, | ||
key: &[u8], | ||
element: Element, | ||
transaction: TransactionArg, | ||
drive_operations: Option<&mut Vec<LowLevelDriveOperation>>, | ||
drive_version: &DriveVersion, | ||
) -> Result<Option<Element>, Error> { | ||
match drive_version.grove_methods.basic.grove_insert_if_not_exists { | ||
0 => self.grove_insert_if_not_exists_return_existing_element_v0( | ||
path, | ||
key, | ||
element, | ||
transaction, | ||
drive_operations, | ||
drive_version, | ||
), | ||
version => Err(Error::Drive(DriveError::UnknownVersionMismatch { | ||
method: "grove_insert_if_not_exists_return_existing_element".to_string(), | ||
known_versions: vec![0], | ||
received: version, | ||
})), | ||
} | ||
} | ||
} |
60 changes: 30 additions & 30 deletions
60
...ve/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/v0/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
// use crate::drive::Drive; | ||
// use crate::error::Error; | ||
// use crate::fees::op::LowLevelDriveOperation; | ||
// use crate::util::grove_operations::push_drive_operation_result_optional; | ||
// use grovedb::{Element, TransactionArg}; | ||
// use grovedb_path::SubtreePath; | ||
// use platform_version::version::drive_versions::DriveVersion; | ||
// | ||
// impl Drive { | ||
// /// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist | ||
// /// to `drive_operations`. | ||
// pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0<B: AsRef<[u8]>>( | ||
// &self, | ||
// path: SubtreePath<'_, B>, | ||
// key: &[u8], | ||
// element: Element, | ||
// transaction: TransactionArg, | ||
// drive_operations: Option<&mut Vec<LowLevelDriveOperation>>, | ||
// drive_version: &DriveVersion, | ||
// ) -> Result<bool, Error> { | ||
// let cost_context = self.grove.insert_if_not_exists_return_existing_element( | ||
// path, | ||
// key, | ||
// element, | ||
// transaction, | ||
// &drive_version.grove_version, | ||
// ); | ||
// push_drive_operation_result_optional(cost_context, drive_operations) | ||
// } | ||
// } | ||
use crate::drive::Drive; | ||
use crate::error::Error; | ||
use crate::fees::op::LowLevelDriveOperation; | ||
use crate::util::grove_operations::push_drive_operation_result_optional; | ||
use grovedb::{Element, TransactionArg}; | ||
use grovedb_path::SubtreePath; | ||
use platform_version::version::drive_versions::DriveVersion; | ||
|
||
impl Drive { | ||
/// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist | ||
/// to `drive_operations`. | ||
pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0<B: AsRef<[u8]>>( | ||
&self, | ||
path: SubtreePath<'_, B>, | ||
key: &[u8], | ||
element: Element, | ||
transaction: TransactionArg, | ||
drive_operations: Option<&mut Vec<LowLevelDriveOperation>>, | ||
drive_version: &DriveVersion, | ||
) -> Result<Option<Element>, Error> { | ||
let cost_context = self.grove.insert_if_not_exists_return_existing_element( | ||
path, | ||
key, | ||
element, | ||
transaction, | ||
&drive_version.grove_version, | ||
); | ||
push_drive_operation_result_optional(cost_context, drive_operations) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters