Skip to content

Commit f348496

Browse files
committed
f - use NextHop in PeeledOnion::Forward
1 parent 9853bc7 commit f348496

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ pub(crate) struct ReceiveTlvs {
3333
}
3434

3535
/// The next hop to forward the onion message along its path.
36-
pub(crate) enum NextHop {
36+
#[derive(Debug)]
37+
pub enum NextHop {
3738
/// The node id of the next hop.
3839
NodeId(PublicKey),
3940
/// The short channel id leading to the next hop.

lightning/src/onion_message/messenger.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub trait CustomOnionMessageHandler {
538538
#[derive(Debug)]
539539
pub enum PeeledOnion<T: OnionMessageContents> {
540540
/// Forwarded onion, with the next node id and a new onion
541-
Forward(PublicKey, OnionMessage),
541+
Forward(NextHop, OnionMessage),
542542
/// Received onion message, with decrypted contents, path_id, and reply path
543543
Receive(ParsedOnionMessageContents<T>, Option<[u8; 32]>, Option<BlindedPath>)
544544
}
@@ -685,12 +685,7 @@ where
685685
onion_routing_packet: outgoing_packet,
686686
};
687687

688-
let next_node_id = match next_hop {
689-
NextHop::NodeId(pubkey) => pubkey,
690-
NextHop::ShortChannelId(_) => todo!(),
691-
};
692-
693-
Ok(PeeledOnion::Forward(next_node_id, onion_message))
688+
Ok(PeeledOnion::Forward(next_hop, onion_message))
694689
},
695690
Err(e) => {
696691
log_trace!(logger, "Errored decoding onion message packet: {:?}", e);
@@ -959,7 +954,12 @@ where
959954
},
960955
}
961956
},
962-
Ok(PeeledOnion::Forward(next_node_id, onion_message)) => {
957+
Ok(PeeledOnion::Forward(next_hop, onion_message)) => {
958+
let next_node_id = match next_hop {
959+
NextHop::NodeId(pubkey) => pubkey,
960+
NextHop::ShortChannelId(_) => todo!(),
961+
};
962+
963963
let mut message_recipients = self.message_recipients.lock().unwrap();
964964
if outbound_buffer_full(&next_node_id, &message_recipients) {
965965
log_trace!(self.logger, "Dropping forwarded onion message to peer {:?}: outbound buffer full", next_node_id);

0 commit comments

Comments
 (0)