Skip to content

Commit 95b3ef4

Browse files
Normalize order of (sha256_of_onion, failure_code) in trait.
This helps avoid destructuring the tuple.
1 parent 04e70ba commit 95b3ef4

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lightning/src/ln/channel.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -2543,26 +2543,24 @@ impl FailHTLCContents for msgs::OnionErrorPacket {
25432543
HTLCUpdateAwaitingACK::FailHTLC { htlc_id, err_packet: self }
25442544
}
25452545
}
2546-
impl FailHTLCContents for (u16, [u8; 32]) {
2546+
impl FailHTLCContents for ([u8; 32], u16) {
25472547
type Message = msgs::UpdateFailMalformedHTLC; // (failure_code, sha256_of_onion)
25482548
fn to_message(self, htlc_id: u64, channel_id: ChannelId) -> Self::Message {
25492549
msgs::UpdateFailMalformedHTLC {
25502550
htlc_id,
25512551
channel_id,
2552-
failure_code: self.0,
2553-
sha256_of_onion: self.1
2552+
sha256_of_onion: self.0,
2553+
failure_code: self.1
25542554
}
25552555
}
25562556
fn to_inbound_htlc_state(self) -> InboundHTLCState {
2557-
InboundHTLCState::LocalRemoved(
2558-
InboundHTLCRemovalReason::FailMalformed((self.1, self.0))
2559-
)
2557+
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(self))
25602558
}
25612559
fn to_htlc_update_awaiting_ack(self, htlc_id: u64) -> HTLCUpdateAwaitingACK {
25622560
HTLCUpdateAwaitingACK::FailMalformedHTLC {
25632561
htlc_id,
2564-
failure_code: self.0,
2565-
sha256_of_onion: self.1
2562+
sha256_of_onion: self.0,
2563+
failure_code: self.1
25662564
}
25672565
}
25682566
}
@@ -2888,7 +2886,7 @@ impl<SP: Deref> Channel<SP> where
28882886
pub fn queue_fail_malformed_htlc<L: Deref>(
28892887
&mut self, htlc_id_arg: u64, failure_code: u16, sha256_of_onion: [u8; 32], logger: &L
28902888
) -> Result<(), ChannelError> where L::Target: Logger {
2891-
self.fail_htlc(htlc_id_arg, (failure_code, sha256_of_onion), true, logger)
2889+
self.fail_htlc(htlc_id_arg, (sha256_of_onion, failure_code), true, logger)
28922890
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
28932891
}
28942892

@@ -3625,7 +3623,7 @@ impl<SP: Deref> Channel<SP> where
36253623
.map(|fail_msg_opt| fail_msg_opt.map(|_| ())))
36263624
},
36273625
&HTLCUpdateAwaitingACK::FailMalformedHTLC { htlc_id, failure_code, sha256_of_onion } => {
3628-
Some(self.fail_htlc(htlc_id, (failure_code, sha256_of_onion), false, logger)
3626+
Some(self.fail_htlc(htlc_id, (sha256_of_onion, failure_code), false, logger)
36293627
.map(|fail_msg_opt| fail_msg_opt.map(|_| ())))
36303628
}
36313629
};

0 commit comments

Comments
 (0)