From 0b18b5f6c32ddafedc59293719a87601d0ac44b9 Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 29 Sep 2024 11:40:46 +0800 Subject: [PATCH] clippy bless --- src/fiber/channel.rs | 34 ++++++++++++++-------------------- src/fiber/network.rs | 10 +++++----- src/store.rs | 6 +++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/fiber/channel.rs b/src/fiber/channel.rs index c5561b56..4778816f 100644 --- a/src/fiber/channel.rs +++ b/src/fiber/channel.rs @@ -456,13 +456,12 @@ where { Ok((added_tlc_id, forward_to_next_hop)) => { if forward_to_next_hop { - let _ = self - .handle_forward_onion_packet( - state, - add_tlc.onion_packet, - added_tlc_id.into(), - ) - .await?; + self.handle_forward_onion_packet( + state, + add_tlc.onion_packet, + added_tlc_id.into(), + ) + .await?; } Ok(()) } @@ -482,7 +481,7 @@ where state.get_remote_peer_id(), FiberMessage::remove_tlc(RemoveTlc { channel_id: state.get_id(), - tlc_id: tlc_id, + tlc_id, reason: RemoveTlcReason::RemoveTlcFail( RemoveTlcFail { //FIXME: we should define the error code carefully according @@ -704,12 +703,10 @@ where onion_info.amount, add_tlc.amount) )); } - if !forward_to_next_hop { - if onion_info.amount != add_tlc.amount { - return Err(ProcessingChannelError::InvalidParameter( - "Payment amount mismatch".to_string(), - )); - } + if !forward_to_next_hop && onion_info.amount != add_tlc.amount { + return Err(ProcessingChannelError::InvalidParameter( + "Payment amount mismatch".to_string(), + )); } // TODO: check the expiry time, if expired, we should return an error. @@ -753,7 +750,7 @@ where NetworkActorCommand::SendOnionPacket( SendOnionPacketCommand { packet: onion_packet, - previous_tlc: Some((state.get_id(), added_tlc_id.into())), + previous_tlc: Some((state.get_id(), added_tlc_id)), }, rpc_reply, ), @@ -6040,7 +6037,7 @@ mod tests { }) .await; - let remove_tlc_result = call!(node_b.network_actor, |rpc_reply| { + call!(node_b.network_actor, |rpc_reply| { NetworkActorMessage::Command(NetworkActorCommand::ControlFiberChannel( ChannelCommandWithId { channel_id: new_channel_id, @@ -6059,8 +6056,6 @@ mod tests { .expect("node_b alive") .expect("successfully removed tlc"); - dbg!(&remove_tlc_result); - // Since we currently automatically send a `CommitmentSigned` message // after sending a `RemoveTlc` message, we can expect the `RemoteCommitmentSigned` // to be received by node a. @@ -6547,8 +6542,7 @@ mod tests { }) .await; - let _ = node_a - .network_actor + network_actor .send_message(NetworkActorMessage::Command( NetworkActorCommand::ControlFiberChannel(ChannelCommandWithId { channel_id: new_channel_id, diff --git a/src/fiber/network.rs b/src/fiber/network.rs index c06fa563..9a562a76 100644 --- a/src/fiber/network.rs +++ b/src/fiber/network.rs @@ -560,7 +560,7 @@ where let auto_accept = if let Some(udt_type_script) = open_channel.funding_udt_type_script.as_ref() { - is_udt_type_auto_accept(&udt_type_script, open_channel.funding_amount) + is_udt_type_auto_accept(udt_type_script, open_channel.funding_amount) } else { state.auto_accept_channel_ckb_funding_amount > 0 && open_channel.all_ckb_amount() @@ -1718,7 +1718,7 @@ where }; if let Err(err) = secp256k1_instance().verify_schnorr( - &ckb_signature, + ckb_signature, &Message::from_digest(message), &channel_announcement.ckb_key, ) { @@ -2519,14 +2519,14 @@ where } async fn get_funding_lock_script(&self) -> Script { - let funding_lock_script = call!( + + call!( self.chain_actor, CkbChainMessage::GetFundingSourceScript, () ) .expect(ASSUME_CHAIN_ACTOR_ALWAYS_ALIVE_FOR_NOW) - .expect("Get funding source script from chain"); - funding_lock_script + .expect("Get funding source script from chain") } fn get_peer_session(&self, peer_id: &PeerId) -> Option { diff --git a/src/store.rs b/src/store.rs index c4a31bf2..1f47441c 100644 --- a/src/store.rs +++ b/src/store.rs @@ -379,7 +379,7 @@ impl NetworkGraphStateStore for Store { .take_while(|(key, _)| key.starts_with(&channel_prefix)) .filter_map(|(col_key, value)| { if let Some(key) = &outpoint_key { - if !col_key.starts_with(&key) { + if !col_key.starts_with(key) { return None; } } @@ -427,7 +427,7 @@ impl NetworkGraphStateStore for Store { .take_while(|(key, _)| key.starts_with(&node_prefix)) .filter_map(|(col_key, value)| { if let Some(key) = &node_key { - if !col_key.starts_with(&key) { + if !col_key.starts_with(key) { return None; } } @@ -667,7 +667,7 @@ mod tests { } // sort by out_point - channels.sort_by(|a, b| a.out_point().cmp(&b.out_point())); + channels.sort_by_key(|a| a.out_point()); let outpoint_0 = channels[0].out_point(); assert_eq!(