Skip to content

Commit c2035b5

Browse files
committed
Cargo fmt
1 parent 379ad04 commit c2035b5

File tree

9 files changed

+54
-33
lines changed

9 files changed

+54
-33
lines changed

firewood/src/db.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ use metrics::{counter, describe_counter};
1414
use std::io::Write;
1515
use std::path::Path;
1616
use std::sync::{Arc, RwLock};
17-
use storage::{Committed, FileBacked, FileIoError, HashedNodeReader, ImmutableProposal, NodeStore, TrieHash};
18-
use typed_builder::TypedBuilder;
17+
use storage::{
18+
Committed, FileBacked, FileIoError, HashedNodeReader, ImmutableProposal, NodeStore, TrieHash,
19+
};
1920
use thiserror::Error;
21+
use typed_builder::TypedBuilder;
2022

2123
#[derive(Error, Debug)]
2224
/// Represents the different types of errors that can occur in the database.

firewood/src/diff.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// See the file LICENSE.md for licensing terms.
33

44
use storage::{
5-
FileIoError, Node, NodeStore, Parentable, ReadInMemoryNode, ReadableStorage, RootReader, TrieHash, TrieReader
5+
FileIoError, Node, NodeStore, Parentable, ReadInMemoryNode, ReadableStorage, RootReader,
6+
TrieHash, TrieReader,
67
};
78

89
use crate::{
@@ -79,16 +80,14 @@ where
7980
match (left_item, right_item) {
8081
(Some(left_item), Some(right_item)) => {
8182
match *left_item?.node {
82-
Node::Leaf(ref _left_leaf) => {
83-
match *right_item?.node {
84-
Node::Leaf(ref _right_leaf) => {
85-
todo!()
86-
}
87-
Node::Branch(ref _right_branch) => {
88-
todo!()
89-
}
83+
Node::Leaf(ref _left_leaf) => match *right_item?.node {
84+
Node::Leaf(ref _right_leaf) => {
85+
todo!()
9086
}
91-
}
87+
Node::Branch(ref _right_branch) => {
88+
todo!()
89+
}
90+
},
9291
Node::Branch(ref _left_branch) => {
9392
match *right_item?.node {
9493
Node::Branch(ref _right_branch) => {

firewood/src/manager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use crate::merkle::Merkle;
1313
use crate::v2::api::HashKey;
1414

1515
pub use storage::CacheReadStrategy;
16-
use storage::{Committed, FileBacked, FileIoError, ImmutableProposal, NodeStore, Parentable, TrieHash};
16+
use storage::{
17+
Committed, FileBacked, FileIoError, ImmutableProposal, NodeStore, Parentable, TrieHash,
18+
};
1719

1820
#[derive(Clone, Debug, TypedBuilder)]
1921
/// Revision manager configuratoin
@@ -55,9 +57,7 @@ pub(crate) enum RevisionManagerError {
5557
"The proposal cannot be committed since it is not a direct child of the most recent commit"
5658
)]
5759
NotLatest,
58-
#[error(
59-
"Revision not found"
60-
)]
60+
#[error("Revision not found")]
6161
RevisionNotFound,
6262
#[error("An IO error occurred during the commit")]
6363
FileIoError(#[from] FileIoError),

firewood/src/merkle.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use std::iter::once;
1515
use std::num::NonZeroUsize;
1616
use std::sync::Arc;
1717
use storage::{
18-
BranchNode, Child, FileIoError, HashType, Hashable, HashedNodeReader, ImmutableProposal, LeafNode, LinearAddress, MutableProposal, NibblesIterator, Node, NodeStore, Path, ReadableStorage, SharedNode, TrieReader, ValueDigest
18+
BranchNode, Child, FileIoError, HashType, Hashable, HashedNodeReader, ImmutableProposal,
19+
LeafNode, LinearAddress, MutableProposal, NibblesIterator, Node, NodeStore, Path,
20+
ReadableStorage, SharedNode, TrieReader, ValueDigest,
1921
};
2022

2123
/// Keys are boxed u8 slices
@@ -204,7 +206,10 @@ impl<T: TrieReader> Merkle<T> {
204206
todo!()
205207
}
206208

207-
pub(crate) fn path_iter<'a>(&self, key: &'a [u8]) -> Result<PathIterator<'_, 'a, T>, FileIoError> {
209+
pub(crate) fn path_iter<'a>(
210+
&self,
211+
key: &'a [u8],
212+
) -> Result<PathIterator<'_, 'a, T>, FileIoError> {
208213
PathIterator::new(&self.nodestore, key)
209214
}
210215

@@ -380,7 +385,11 @@ impl<T: HashedNodeReader> Merkle<T> {
380385
pub(crate) fn dump(&self) -> Result<String, Error> {
381386
let mut result = String::new();
382387
writeln!(result, "digraph Merkle {{\n rankdir=LR;").map_err(Error::other)?;
383-
if let Some((root_addr, root_hash)) = self.nodestore.root_address_and_hash().expect("failed to get root address and hash") {
388+
if let Some((root_addr, root_hash)) = self
389+
.nodestore
390+
.root_address_and_hash()
391+
.expect("failed to get root address and hash")
392+
{
384393
writeln!(result, " root -> {root_addr}").map_err(Error::other)?;
385394
let mut seen = HashSet::new();
386395
// If ethhash is off, root_hash.into() is already the correct type

firewood/src/proof.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
use sha2::{Digest, Sha256};
55
use storage::{
6-
BranchNode, FileIoError, HashType, Hashable, NibblesIterator, PathIterItem, Preimage, TrieHash, ValueDigest
6+
BranchNode, FileIoError, HashType, Hashable, NibblesIterator, PathIterItem, Preimage, TrieHash,
7+
ValueDigest,
78
};
89
use thiserror::Error;
910

firewood/src/stream.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use futures::{Stream, StreamExt};
99
use std::cmp::Ordering;
1010
use std::iter::{FusedIterator, once};
1111
use std::task::Poll;
12-
use storage::{BranchNode, Child, FileIoError, NibblesIterator, Node, PathIterItem, SharedNode, TrieReader};
12+
use storage::{
13+
BranchNode, Child, FileIoError, NibblesIterator, Node, PathIterItem, SharedNode, TrieReader,
14+
};
1315

1416
/// Represents an ongoing iteration over a node and its children.
1517
enum IterationNode {

storage/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub mod logger;
2323

2424
// re-export these so callers don't need to know where they are
2525
pub use hashednode::{Hashable, Preimage, ValueDigest, hash_node, hash_preimage};
26-
pub use linear::{ReadableStorage, WritableStorage, FileIoError};
26+
pub use linear::{FileIoError, ReadableStorage, WritableStorage};
2727
pub use node::path::{NibblesIterator, Path};
2828
pub use node::{BranchNode, Child, LeafNode, Node, PathIterItem, branch::HashType};
2929
pub use nodestore::{

storage/src/linear/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ impl std::fmt::Display for FileIoError {
4949
"{inner} at offset {offset} of file '{filename}' {context}",
5050
inner = self.inner,
5151
offset = self.offset,
52-
filename = self.filename.as_ref().unwrap_or(&PathBuf::from("[unknown]")).display(),
52+
filename = self
53+
.filename
54+
.as_ref()
55+
.unwrap_or(&PathBuf::from("[unknown]"))
56+
.display(),
5357
context = self.context.as_ref().unwrap_or(&String::from(""))
5458
)
5559
}

storage/src/nodestore.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,11 +1196,13 @@ impl NodeStore<Arc<ImmutableProposal>, FileBacked> {
11961196
// if we get here, that means we couldn't find a place to queue the request, so wait for at least one operation
11971197
// to complete, then handle the completion queue
11981198
counter!("ring.full").increment(1);
1199-
ring.submit_and_wait(1).map_err(|e| self.storage.file_io_error(
1200-
e,
1201-
0,
1202-
Some("uring submission queue submit and wait".to_string()),
1203-
))?;
1199+
ring.submit_and_wait(1).map_err(|e| {
1200+
self.storage.file_io_error(
1201+
e,
1202+
0,
1203+
Some("uring submission queue submit and wait".to_string()),
1204+
)
1205+
})?;
12041206
let completion_queue = ring.completion();
12051207
trace!("competion queue length: {}", completion_queue.len());
12061208
for entry in completion_queue {
@@ -1216,11 +1218,13 @@ impl NodeStore<Arc<ImmutableProposal>, FileBacked> {
12161218
.iter()
12171219
.filter(|(busy, _)| *busy)
12181220
.count();
1219-
ring.submit_and_wait(pending).map_err(|e| self.storage.file_io_error(
1220-
e,
1221-
0,
1222-
Some("uring submission queue submit and wait".to_string()),
1223-
))?;
1221+
ring.submit_and_wait(pending).map_err(|e| {
1222+
self.storage.file_io_error(
1223+
e,
1224+
0,
1225+
Some("uring submission queue submit and wait".to_string()),
1226+
)
1227+
})?;
12241228

12251229
for entry in ring.completion() {
12261230
let item = entry.user_data() as usize;

0 commit comments

Comments
 (0)