Skip to content

Commit

Permalink
clippy bless
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Sep 29, 2024
1 parent 8665722 commit 9292ffa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
33 changes: 14 additions & 19 deletions src/fiber/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -6547,7 +6542,7 @@ mod tests {
})
.await;

let _ = node_a
node_a
.network_actor
.send_message(NetworkActorMessage::Command(
NetworkActorCommand::ControlFiberChannel(ChannelCommandWithId {
Expand Down
10 changes: 5 additions & 5 deletions src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
) {
Expand Down Expand Up @@ -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<SessionId> {
Expand Down
6 changes: 3 additions & 3 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 9292ffa

Please sign in to comment.