Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump GroveDB dependency #2196

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/rs-drive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ enum-map = { version = "2.0.3", optional = true }
intmap = { version = "2.0.0", features = ["serde"], optional = true }
chrono = { version = "0.4.35", optional = true }
itertools = { version = "0.11.0", optional = true }
grovedb = { version = "2.0.3", optional = true, default-features = false }
grovedb-costs = { version = "2.0.3", optional = true }
grovedb-path = { version = "2.0.3" }
grovedb-storage = { version = "2.0.3", optional = true }
grovedb-version = { version = "2.0.3"}
grovedb-epoch-based-storage-flags = { version = "2.0.3"}
grovedb = { version = "2.1.0", optional = true, default-features = false }
grovedb-costs = { version = "2.1.0", optional = true }
grovedb-path = { version = "2.1.0" }
grovedb-storage = { version = "2.1.0", optional = true }
grovedb-version = { version = "2.1.0"}
grovedb-epoch-based-storage-flags = { version = "2.1.0"}

[dev-dependencies]
criterion = "0.3.5"
Expand Down
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,
})),
}
}
}
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)
}
QuantumExplorer marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion packages/rs-platform-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"
thiserror = { version = "1.0.63" }
bincode = { version = "2.0.0-rc.3"}
versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" }
grovedb-version = { version = "2.0.3"}
grovedb-version = { version = "2.1.0"}
once_cell = "1.19.0"

[features]
Expand Down
Loading