Skip to content

Commit 37b5ea4

Browse files
chore: bump GroveDB dependency (#2196)
Co-authored-by: Quantum Explorer <[email protected]>
1 parent 6230b53 commit 37b5ea4

File tree

5 files changed

+109
-109
lines changed

5 files changed

+109
-109
lines changed

Cargo.lock

Lines changed: 19 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/rs-drive/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ enum-map = { version = "2.0.3", optional = true }
5151
intmap = { version = "2.0.0", features = ["serde"], optional = true }
5252
chrono = { version = "0.4.35", optional = true }
5353
itertools = { version = "0.11.0", optional = true }
54-
grovedb = { version = "2.0.3", optional = true, default-features = false }
55-
grovedb-costs = { version = "2.0.3", optional = true }
56-
grovedb-path = { version = "2.0.3" }
57-
grovedb-storage = { version = "2.0.3", optional = true }
58-
grovedb-version = { version = "2.0.3"}
59-
grovedb-epoch-based-storage-flags = { version = "2.0.3"}
54+
grovedb = { version = "2.1.0", optional = true, default-features = false }
55+
grovedb-costs = { version = "2.1.0", optional = true }
56+
grovedb-path = { version = "2.1.0" }
57+
grovedb-storage = { version = "2.1.0", optional = true }
58+
grovedb-version = { version = "2.1.0"}
59+
grovedb-epoch-based-storage-flags = { version = "2.1.0"}
6060

6161
[dev-dependencies]
6262
criterion = "0.3.5"
Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
//todo: uncomment once version 2.1 of GroveDB is released.
2-
// mod v0;
3-
//
4-
// use crate::drive::Drive;
5-
// use crate::error::drive::DriveError;
6-
// use crate::error::Error;
7-
// use crate::fees::op::LowLevelDriveOperation;
8-
// use dpp::version::drive_versions::DriveVersion;
9-
// use grovedb::{Element, TransactionArg};
10-
// use grovedb_path::SubtreePath;
11-
//
12-
// impl Drive {
13-
// /// Inserts an element into groveDB only if the specified path and key do not exist.
14-
// /// This operation costs are then stored in `drive_operations`.
15-
// ///
16-
// /// # Parameters
17-
// /// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted.
18-
// /// * `key`: The key where the new element should be inserted in the subtree.
19-
// /// * `element`: The element to be inserted.
20-
// /// * `transaction`: The groveDB transaction associated with this operation.
21-
// /// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case,
22-
// /// it collects the cost of this insert operation if the path and key did not exist.
23-
// /// * `platform_version`: The platform version to select the correct function version to run.
24-
// ///
25-
// /// # Returns
26-
// /// * `Ok(true)` if the insertion was successful.
27-
// /// * `Ok(false)` if the path and key already existed.
28-
// /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
29-
// pub fn grove_insert_if_not_exists_return_existing_element<B: AsRef<[u8]>>(
30-
// &self,
31-
// path: SubtreePath<'_, B>,
32-
// key: &[u8],
33-
// element: Element,
34-
// transaction: TransactionArg,
35-
// drive_operations: Option<&mut Vec<LowLevelDriveOperation>>,
36-
// drive_version: &DriveVersion,
37-
// ) -> Result<Option<Element>, Error> {
38-
// match drive_version.grove_methods.basic.grove_insert_if_not_exists {
39-
// 0 => self.grove_insert_if_not_exists_return_existing_element_v0(
40-
// path,
41-
// key,
42-
// element,
43-
// transaction,
44-
// drive_operations,
45-
// drive_version,
46-
// ),
47-
// version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
48-
// method: "grove_insert_if_not_exists_return_existing_element".to_string(),
49-
// known_versions: vec![0],
50-
// received: version,
51-
// })),
52-
// }
53-
// }
54-
// }
1+
mod v0;
2+
3+
use crate::drive::Drive;
4+
use crate::error::drive::DriveError;
5+
use crate::error::Error;
6+
use crate::fees::op::LowLevelDriveOperation;
7+
use dpp::version::drive_versions::DriveVersion;
8+
use grovedb::{Element, TransactionArg};
9+
use grovedb_path::SubtreePath;
10+
11+
impl Drive {
12+
/// Inserts an element into groveDB only if the specified path and key do not exist.
13+
/// This operation costs are then stored in `drive_operations`.
14+
///
15+
/// # Parameters
16+
/// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted.
17+
/// * `key`: The key where the new element should be inserted in the subtree.
18+
/// * `element`: The element to be inserted.
19+
/// * `transaction`: The groveDB transaction associated with this operation.
20+
/// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case,
21+
/// it collects the cost of this insert operation if the path and key did not exist.
22+
/// * `platform_version`: The platform version to select the correct function version to run.
23+
///
24+
/// # Returns
25+
/// * `Ok(true)` if the insertion was successful.
26+
/// * `Ok(false)` if the path and key already existed.
27+
/// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
28+
pub fn grove_insert_if_not_exists_return_existing_element<B: AsRef<[u8]>>(
29+
&self,
30+
path: SubtreePath<'_, B>,
31+
key: &[u8],
32+
element: Element,
33+
transaction: TransactionArg,
34+
drive_operations: Option<&mut Vec<LowLevelDriveOperation>>,
35+
drive_version: &DriveVersion,
36+
) -> Result<Option<Element>, Error> {
37+
match drive_version.grove_methods.basic.grove_insert_if_not_exists {
38+
0 => self.grove_insert_if_not_exists_return_existing_element_v0(
39+
path,
40+
key,
41+
element,
42+
transaction,
43+
drive_operations,
44+
drive_version,
45+
),
46+
version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
47+
method: "grove_insert_if_not_exists_return_existing_element".to_string(),
48+
known_versions: vec![0],
49+
received: version,
50+
})),
51+
}
52+
}
53+
}
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
// use crate::drive::Drive;
2-
// use crate::error::Error;
3-
// use crate::fees::op::LowLevelDriveOperation;
4-
// use crate::util::grove_operations::push_drive_operation_result_optional;
5-
// use grovedb::{Element, TransactionArg};
6-
// use grovedb_path::SubtreePath;
7-
// use platform_version::version::drive_versions::DriveVersion;
8-
//
9-
// impl Drive {
10-
// /// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist
11-
// /// to `drive_operations`.
12-
// pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0<B: AsRef<[u8]>>(
13-
// &self,
14-
// path: SubtreePath<'_, B>,
15-
// key: &[u8],
16-
// element: Element,
17-
// transaction: TransactionArg,
18-
// drive_operations: Option<&mut Vec<LowLevelDriveOperation>>,
19-
// drive_version: &DriveVersion,
20-
// ) -> Result<bool, Error> {
21-
// let cost_context = self.grove.insert_if_not_exists_return_existing_element(
22-
// path,
23-
// key,
24-
// element,
25-
// transaction,
26-
// &drive_version.grove_version,
27-
// );
28-
// push_drive_operation_result_optional(cost_context, drive_operations)
29-
// }
30-
// }
1+
use crate::drive::Drive;
2+
use crate::error::Error;
3+
use crate::fees::op::LowLevelDriveOperation;
4+
use crate::util::grove_operations::push_drive_operation_result_optional;
5+
use grovedb::{Element, TransactionArg};
6+
use grovedb_path::SubtreePath;
7+
use platform_version::version::drive_versions::DriveVersion;
8+
9+
impl Drive {
10+
/// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist
11+
/// to `drive_operations`.
12+
pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0<B: AsRef<[u8]>>(
13+
&self,
14+
path: SubtreePath<'_, B>,
15+
key: &[u8],
16+
element: Element,
17+
transaction: TransactionArg,
18+
drive_operations: Option<&mut Vec<LowLevelDriveOperation>>,
19+
drive_version: &DriveVersion,
20+
) -> Result<Option<Element>, Error> {
21+
let cost_context = self.grove.insert_if_not_exists_return_existing_element(
22+
path,
23+
key,
24+
element,
25+
transaction,
26+
&drive_version.grove_version,
27+
);
28+
push_drive_operation_result_optional(cost_context, drive_operations)
29+
}
30+
}

packages/rs-platform-version/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "MIT"
1111
thiserror = { version = "1.0.63" }
1212
bincode = { version = "2.0.0-rc.3"}
1313
versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" }
14-
grovedb-version = { version = "2.0.3"}
14+
grovedb-version = { version = "2.1.0"}
1515
once_cell = "1.19.0"
1616

1717
[features]

0 commit comments

Comments
 (0)