Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed May 13, 2024
1 parent 8cdba11 commit a926a66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
53 changes: 25 additions & 28 deletions grovedb/src/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ use std::{
};

use grovedb_merk::{
ed::Encode,
merk::restore::Restorer,
proofs::Op,
proofs::{Decoder, Op},
tree::{hash::CryptoHash, kv::ValueDefinedCostType, value_hash},
ChunkProducer,
};
use grovedb_merk::ed::Encode;
use grovedb_merk::proofs::Decoder;
use grovedb_path::SubtreePath;
use grovedb_storage::rocksdb_storage::RocksDbStorage;
#[rustfmt::skip]
Expand Down Expand Up @@ -113,9 +112,7 @@ pub fn util_split_global_chunk_id(
Ok((chunk_prefix_key, chunk_id.to_vec()))
}

pub fn util_encode_vec_ops(
chunk: Vec<Op>,
) -> Result<Vec<u8>, Error> {
pub fn util_encode_vec_ops(chunk: Vec<Op>) -> Result<Vec<u8>, Error> {
let mut res = vec![];
for op in chunk {
if op.encode_into(&mut res).is_err() {
Expand All @@ -126,9 +123,7 @@ pub fn util_encode_vec_ops(
Ok(res)
}

pub fn util_decode_vec_ops(
chunk: Vec<u8>,
) -> Result<Vec<Op>, Error> {
pub fn util_decode_vec_ops(chunk: Vec<u8>) -> Result<Vec<Op>, Error> {
let mut decoder = Decoder::new(&chunk);

Check warning on line 127 in grovedb/src/replication.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> grovedb/src/replication.rs:127:9 | 127 | let mut decoder = Decoder::new(&chunk); | ----^^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
let mut res = vec![];
for op in decoder {
Expand Down Expand Up @@ -294,13 +289,11 @@ impl GroveDb {
Ok(mut chunk_producer) => {
let chunk_res = chunk_producer.chunk(chunk_id);
match chunk_res {
Ok((chunk, _)) => {
match util_encode_vec_ops(chunk) {
Ok(op_bytes) => Ok(op_bytes),
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
)),
}
Ok((chunk, _)) => match util_encode_vec_ops(chunk) {
Ok(op_bytes) => Ok(op_bytes),
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
)),
},
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
Expand All @@ -326,13 +319,11 @@ impl GroveDb {
Ok(mut chunk_producer) => {
let chunk_res = chunk_producer.chunk(chunk_id);
match chunk_res {
Ok((chunk, _)) => {
match util_encode_vec_ops(chunk) {
Ok(op_bytes) => Ok(op_bytes),
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
)),
}
Ok((chunk, _)) => match util_encode_vec_ops(chunk) {
Ok(op_bytes) => Ok(op_bytes),
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
)),
},
Err(_) => Err(Error::CorruptedData(
"Unable to create to load chunk".to_string(),
Expand Down Expand Up @@ -538,17 +529,23 @@ impl GroveDb {
Ok(next_chunk_ids) => {
state_sync_info.num_processed_chunks += 1;
for next_chunk_id in next_chunk_ids {
state_sync_info.pending_chunks.insert(next_chunk_id.clone());
state_sync_info
.pending_chunks
.insert(next_chunk_id.clone());
res.push(next_chunk_id);
}
}
_ => {
return Err(Error::InternalError("Unable to process incoming chunk"));
return Err(Error::InternalError(
"Unable to process incoming chunk",
));
}
};
},
}
Err(_) => {
return Err(Error::CorruptedData("Unable to decode incoming chunk".to_string()));
return Err(Error::CorruptedData(
"Unable to decode incoming chunk".to_string(),
));
}
}
}
Expand Down Expand Up @@ -611,4 +608,4 @@ impl GroveDb {

Ok((res, state_sync_info))
}
}
}
2 changes: 1 addition & 1 deletion merk/src/proofs/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ impl<'a> Iterator for Decoder<'a> {
mod test {
use super::super::{Node, Op};
use crate::{
proofs::Decoder,
tree::HASH_LENGTH,
TreeFeatureType::{BasicMerkNode, SummedMerkNode},
};
use crate::proofs::Decoder;

#[test]
fn encode_push_hash() {
Expand Down

0 comments on commit a926a66

Please sign in to comment.