Skip to content

Commit

Permalink
f - don't hardcode Iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkczyz committed Jan 14, 2023
1 parent 3ebce4b commit 8c76a69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lightning/src/offers/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ impl TryFrom<Vec<u8>> for Invoice {
}

tlv_stream!(InvoiceTlvStream, InvoiceTlvStreamRef, 160..240, {
(160, paths: (Vec<BlindedPath>, Iterable<'a, BlindedPathIter<'a>, BlindedPath>)),
(162, blindedpay: (Vec<BlindedPayInfo>, Iterable<'a, BlindedPayInfoIter<'a>, BlindedPayInfo>)),
(160, paths: (Vec<BlindedPath>, WithoutLength, Iterable<'a, BlindedPathIter<'a>, BlindedPath>)),
(162, blindedpay: (Vec<BlindedPayInfo>, WithoutLength, Iterable<'a, BlindedPayInfoIter<'a>, BlindedPayInfo>)),
(164, created_at: (u64, HighZeroBytesDroppedBigSize)),
(166, relative_expiry: (u32, HighZeroBytesDroppedBigSize)),
(168, payment_hash: PaymentHash),
Expand Down
13 changes: 4 additions & 9 deletions lightning/src/util/ser_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,8 @@ macro_rules! decode_tlv {
($reader: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
$field = Some($trait::read(&mut $reader $(, $read_arg)*)?);
}};
($reader: expr, $field: ident, (option, encoding: ($fieldty: ty, Iterable<$lifetime:lifetime, $itertype:ty, $valuetype:ty>))) => {{
$field = {
let field: $crate::util::ser::WithoutLength<$fieldty> = ser::Readable::read(&mut $reader)?;
Some(field.0)
};
($reader: expr, $field: ident, (option, encoding: ($fieldty: ty, $encoding: ident, $encoder:ty))) => {{
decode_tlv!($reader, $field, (option, encoding: ($fieldty, $encoding)));
}};
($reader: expr, $field: ident, (option, encoding: ($fieldty: ty, $encoding: ident))) => {{
$field = {
Expand Down Expand Up @@ -555,8 +552,8 @@ macro_rules! tlv_stream {
}

macro_rules! tlv_record_type {
(($type:ty, Iterable<$lifetime:lifetime, $itertype:ty, $valuetype:ty>)) => { $type };
(($type:ty, $wrapper:ident)) => { $type };
(($type:ty, $wrapper:ident, $encoder:ty)) => { $type };
($type:ty) => { $type };
}

Expand All @@ -566,10 +563,8 @@ macro_rules! tlv_record_ref_type {
((u16, $wrapper: ident)) => { u16 };
((u32, $wrapper: ident)) => { u32 };
((u64, $wrapper: ident)) => { u64 };
(($type:ty, Iterable<$lifetime:lifetime, $itertype:ty, $valuetype:ty>)) => {
Iterable<$lifetime, $itertype, $valuetype>
};
(($type:ty, $wrapper:ident)) => { &'a $type };
(($type:ty, $wrapper:ident, $encoder:ty)) => { $encoder };
($type:ty) => { &'a $type };
}

Expand Down

0 comments on commit 8c76a69

Please sign in to comment.