Skip to content
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
90 changes: 38 additions & 52 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ quote = "1.0"
syn = { version = "2.0", features = ["extra-traits", "full"] }
env_logger = "0.11"
log = "0.4"
rocksdb = { version = "0.23.0", features = ["multi-threaded-cf"] }
rocksdb = { package = "rust-rocksdb", git = "https://github.com/zaidoon1/rust-rocksdb", branch = "master", features = ["multi-threaded-cf"] }
thiserror = "1.0"
serde = "1.0"
serde_json = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/engine/src/rocksdb_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ impl Engine for RocksdbEngine {
}

fn write(&self, batch: WriteBatch) -> Result<()> {
self.db.write(batch)
self.db.write(&batch)
}

fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) -> Result<()> {
self.db.write_opt(batch, writeopts)
self.db.write_opt(&batch, writeopts)
}

fn set_options(&self, options: &[(&str, &str)]) -> Result<()> {
Expand Down
9 changes: 4 additions & 5 deletions src/raft/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ impl MessageEnvelope {
/// Add authentication to the message
pub fn add_authentication(&mut self, auth: &NodeAuth) -> RaftResult<()> {
// Create serializable data without HMAC for authentication
// Use a simplified message representation for HMAC
let msg_type = match &self.message {
let message_str = match &self.message {
RaftMessage::AppendEntries(_) => "AppendEntries".to_string(),
RaftMessage::AppendEntriesResponse(_) => "AppendEntriesResponse".to_string(),
RaftMessage::Vote(_) => "Vote".to_string(),
Expand All @@ -397,7 +396,7 @@ impl MessageEnvelope {
};
let data_for_hmac = format!(
"{}:{}:{}:{}:{}",
self.message_id, self.from, self.to, self.timestamp, msg_type
self.message_id, self.from, self.to, self.timestamp, message_str
);

self.hmac = Some(auth.generate_hmac(data_for_hmac.as_bytes())?);
Expand All @@ -408,7 +407,7 @@ impl MessageEnvelope {
pub fn verify_authentication(&self, auth: &NodeAuth) -> bool {
if let Some(ref expected_hmac) = self.hmac {
// Recreate the same data format used for HMAC generation
let msg_type = match &self.message {
let message_str = match &self.message {
RaftMessage::AppendEntries(_) => "AppendEntries".to_string(),
RaftMessage::AppendEntriesResponse(_) => "AppendEntriesResponse".to_string(),
RaftMessage::Vote(_) => "Vote".to_string(),
Expand All @@ -422,7 +421,7 @@ impl MessageEnvelope {
};
let data_for_hmac = format!(
"{}:{}:{}:{}:{}",
self.message_id, self.from, self.to, self.timestamp, msg_type
self.message_id, self.from, self.to, self.timestamp, message_str
);

auth.verify_hmac(data_for_hmac.as_bytes(), expected_hmac)
Expand Down
4 changes: 2 additions & 2 deletions src/raft/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl SnapshotManager {

// Write batch when it gets too large
if batch_size >= BATCH_SIZE_LIMIT {
snapshot_db.write(batch).map_err(|e| {
snapshot_db.write(&batch).map_err(|e| {
RaftError::state_machine(format!("Failed to write batch: {}", e))
})?;
batch = rocksdb::WriteBatch::default();
Expand All @@ -185,7 +185,7 @@ impl SnapshotManager {

// Write remaining batch
if batch_size > 0 {
snapshot_db.write(batch).map_err(|e| {
snapshot_db.write(&batch).map_err(|e| {
RaftError::state_machine(format!("Failed to write final batch: {}", e))
})?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/raft/src/storage/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl StorageBackend for RocksDBBackend {
}
}

db.write(batch).map_err(|e| {
db.write(&batch).map_err(|e| {
RaftError::Storage(crate::error::StorageError::rocksdb_with_context(
e,
"RocksDB batch write error",
Expand Down
Loading