Skip to content

Commit

Permalink
fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidson-Souza committed Apr 8, 2024
1 parent 7924d63 commit d13c2a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
4 changes: 2 additions & 2 deletions crates/floresta-cli/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ pub trait JsonRPCClient: Sized {
/// Calls a method on the client
///
/// This should call the appropriated rpc method and return a parsed response or error.
fn call<T: serde::de::DeserializeOwned>(&self, method: &str, params: &[Value]) -> Result<T>
fn call<T>(&self, method: &str, params: &[Value]) -> Result<T>
where
T: for<'a> serde::de::Deserialize<'a> + Debug;
T: for<'a> serde::de::Deserialize<'a> + serde::de::DeserializeOwned + Debug;
}

impl<T: JsonRPCClient> FlorestaRPC for T {
Expand Down
38 changes: 16 additions & 22 deletions crates/floresta-wire/src/p2p_wire/chain_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,13 @@ where
let mut peer2_version = None;
for _ in 0..2 {
if let Ok(Ok(message)) = timeout(Duration::from_secs(60), self.node_rx.recv()).await {
match message {
NodeNotification::FromPeer(peer, message) => match message {
PeerMessages::UtreexoState(state) => {
if peer == peer1 {
peer1_version = Some(state);
} else if peer == peer2 {
peer2_version = Some(state);
}
}
_ => {}
},
if let NodeNotification::FromPeer(peer, PeerMessages::UtreexoState(state)) = message
{
if peer == peer1 {
peer1_version = Some(state);
} else if peer == peer2 {
peer2_version = Some(state);
}
}
}
}
Expand Down Expand Up @@ -411,17 +407,15 @@ where
continue;
}
let (peer1, peer2) = (peer[0].0, peer[1].0);
match self.find_who_is_lying(peer1, peer2).await? {
Some(liar) => {
// if we found a liar, we need to ban them
self.send_to_peer(liar, NodeRequest::Shutdown).await?;
if liar == peer1 {
invalid_accs.insert(peer[0].1.clone());
} else {
invalid_accs.insert(peer[1].1.clone());
}

if let Some(liar) = self.find_who_is_lying(peer1, peer2).await? {
// if we found a liar, we need to ban them
self.send_to_peer(liar, NodeRequest::Shutdown).await?;
if liar == peer1 {
invalid_accs.insert(peer[0].1.clone());
} else {
invalid_accs.insert(peer[1].1.clone());
}
None => {}
}
}
//filter out the invalid accs
Expand Down Expand Up @@ -495,7 +489,7 @@ where
.chain
.validate_block(&block.block, proof, inputs, del_hashes, acc);

if !is_valid.is_ok() {
if is_valid.is_err() {
self.chain.switch_chain(other_tip)?;
self.chain.invalidate_block(fork)?;
}
Expand Down

0 comments on commit d13c2a1

Please sign in to comment.