diff --git a/Cargo.toml b/Cargo.toml index 7dcd6af..eb618cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.6.1" +version = "0.6.2" edition = "2024" rust-version = "1.92" authors = ["init4"] @@ -35,13 +35,13 @@ incremental = false [workspace.dependencies] # internal -signet-hot = { version = "0.6.1", path = "./crates/hot" } -signet-hot-mdbx = { version = "0.6.1", path = "./crates/hot-mdbx" } -signet-cold = { version = "0.6.1", path = "./crates/cold" } -signet-cold-mdbx = { version = "0.6.1", path = "./crates/cold-mdbx" } -signet-cold-sql = { version = "0.6.1", path = "./crates/cold-sql" } -signet-storage = { version = "0.6.1", path = "./crates/storage" } -signet-storage-types = { version = "0.6.1", path = "./crates/types" } +signet-hot = { version = "0.6.2", path = "./crates/hot" } +signet-hot-mdbx = { version = "0.6.2", path = "./crates/hot-mdbx" } +signet-cold = { version = "0.6.2", path = "./crates/cold" } +signet-cold-mdbx = { version = "0.6.2", path = "./crates/cold-mdbx" } +signet-cold-sql = { version = "0.6.2", path = "./crates/cold-sql" } +signet-storage = { version = "0.6.2", path = "./crates/storage" } +signet-storage-types = { version = "0.6.2", path = "./crates/types" } # External, in-house signet-libmdbx = { version = "0.8.0" } diff --git a/crates/hot/src/mem.rs b/crates/hot/src/mem.rs index 475ac87..d326f50 100644 --- a/crates/hot/src/mem.rs +++ b/crates/hot/src/mem.rs @@ -1057,7 +1057,9 @@ impl<'a> DualKeyTraverse for MemKvCursorMut<'a> { return Ok(None); }; let (found_k1, found_k2) = MemKv::split_dual_key(&found_key); - if found_k1.as_ref() != key1 { + // Compare only the relevant prefix of found_k1 with key1 + // found_k1 is MAX_KEY_SIZE bytes, key1 may be shorter + if &found_k1.as_ref()[..key1.len()] != key1 { self.clear_current_key(); return Ok(None); } @@ -1265,11 +1267,10 @@ impl MemKvRoTx { impl HotKvRead for MemKvRwTx { type Error = MemKvError; - type Traverse<'a> = MemKvCursor<'a>; + type Traverse<'a> = MemKvCursorMut<'a>; fn raw_traverse<'a>(&'a self, table: &str) -> Result, Self::Error> { - let table_data = self.guard.get(table).unwrap_or(&EMPTY_TABLE); - Ok(MemKvCursor::new(table_data)) + self.cursor_mut(table) } fn raw_get<'a>( @@ -1318,14 +1319,10 @@ impl HotKvRead for MemKvRwTx { } impl MemKvRwTx { - /// Get a read-only cursor for the specified table - /// Note: This cursor will NOT see pending writes from this transaction - pub fn cursor<'a>(&'a self, table: &str) -> Result, MemKvError> { - if let Some(table_data) = self.guard.get(table) { - Ok(MemKvCursor::new(table_data)) - } else { - Err(MemKvError::HotKv(HotKvError::Inner(format!("Table '{}' not found", table).into()))) - } + /// Get a cursor for the specified table that sees both committed data + /// and pending writes from this transaction. + pub fn cursor<'a>(&'a self, table: &str) -> Result, MemKvError> { + self.cursor_mut(table) } /// Get a mutable cursor for the specified table