Skip to content

Commit

Permalink
f: Removed BlindedPathTlvsRef
Browse files Browse the repository at this point in the history
1. In the following commit the Forward and Receive Tlvs within the
   BlindedPathTlvs will need to be modified.
2. To allow doing this, preemtively update the code to own the code,
   instead of an immutable reference.
  • Loading branch information
shaavan committed Aug 1, 2024
1 parent 5de2990 commit e670584
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ pub(crate) enum BlindedPaymentTlvs {
Receive(ReceiveTlvs),
}

// Used to include forward and receive TLVs in the same iterator for encoding.
#[derive(Clone)]
enum BlindedPaymentTlvsRef<'a> {
Forward(&'a ForwardTlvs),
Receive(&'a ReceiveTlvs),
}

/// Parameters for relaying over a given [`BlindedHop`].
///
/// [`BlindedHop`]: crate::blinded_path::BlindedHop
Expand Down Expand Up @@ -225,7 +218,7 @@ impl Writeable for ReceiveTlvs {
}
}

impl<'a> Writeable for BlindedPaymentTlvsRef<'a> {
impl Writeable for BlindedPaymentTlvs {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
match self {
Self::Forward(tlvs) => tlvs.write(w)?,
Expand Down Expand Up @@ -276,8 +269,8 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
) -> Result<Vec<BlindedHop>, secp256k1::Error> {
let pks = intermediate_nodes.iter().map(|node| &node.node_id)
.chain(core::iter::once(&payee_node_id));
let tlvs = intermediate_nodes.iter().map(|node| BlindedPaymentTlvsRef::Forward(&node.tlvs))
.chain(core::iter::once(BlindedPaymentTlvsRef::Receive(&payee_tlvs)));
let tlvs = intermediate_nodes.iter().map(|node| BlindedPaymentTlvs::Forward(node.tlvs.clone()))
.chain(core::iter::once(BlindedPaymentTlvs::Receive(payee_tlvs)));

utils::construct_blinded_hops(secp_ctx, pks, tlvs, session_priv)
}
Expand Down

0 comments on commit e670584

Please sign in to comment.