Skip to content

Commit 90b1006

Browse files
committed
f - remove tlv_record literal
1 parent 1c82cf9 commit 90b1006

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ macro_rules! encode_tlv {
2626
field.write($stream)?;
2727
}
2828
};
29-
($stream: expr, $type: expr, $field: expr, (tlv_record, ($fieldty:ty, $wrapper:ident))) => {
30-
encode_tlv!($stream, $type, $field.map(|f| $wrapper(f)), option);
29+
($stream: expr, $type: expr, $field: expr, (option, encoding: ($fieldty: ty, $encoding: ident))) => {
30+
encode_tlv!($stream, $type, $field.map(|f| $encoding(f)), option);
3131
};
32-
($stream: expr, $type: expr, $field: expr, (tlv_record, $fieldty:ty)) => {
32+
($stream: expr, $type: expr, $field: expr, (option, encoding: $fieldty: ty)) => {
3333
encode_tlv!($stream, $type, $field, option);
3434
};
3535
}
@@ -127,7 +127,7 @@ macro_rules! check_tlv_order {
127127
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
128128
// no-op
129129
}};
130-
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (tlv_record, $fieldty:tt)) => {{
130+
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (option, encoding: $encoding: tt)) => {{
131131
// no-op
132132
}};
133133
}
@@ -159,7 +159,7 @@ macro_rules! check_missing_tlv {
159159
($last_seen_type: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
160160
// no-op
161161
}};
162-
($last_seen_type: expr, $type: expr, $field: ident, (tlv_record, $fieldty:tt)) => {{
162+
($last_seen_type: expr, $type: expr, $field: ident, (option, encoding: $encoding: tt)) => {{
163163
// no-op
164164
}};
165165
}
@@ -184,13 +184,13 @@ macro_rules! decode_tlv {
184184
($reader: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
185185
$field = Some($trait::read(&mut $reader $(, $read_arg)*)?);
186186
}};
187-
($reader: expr, $field: ident, (tlv_record, ($fieldty:ty, $wrapper:ident))) => {{
187+
($reader: expr, $field: ident, (option, encoding: ($fieldty: ty, $encoding: ident))) => {{
188188
$field = {
189-
let field: $wrapper<$fieldty> = ser::Readable::read(&mut $reader)?;
189+
let field: $encoding<$fieldty> = ser::Readable::read(&mut $reader)?;
190190
Some(field.into())
191191
};
192192
}};
193-
($reader: expr, $field: ident, (tlv_record, $fieldty:ty)) => {{
193+
($reader: expr, $field: ident, (option, encoding: $fieldty: ty)) => {{
194194
decode_tlv!($reader, $field, option);
195195
}};
196196
}
@@ -396,9 +396,6 @@ macro_rules! init_tlv_field_var {
396396
($field: ident, option) => {
397397
let mut $field = None;
398398
};
399-
($field: ident, tlv_record) => {
400-
let mut $field = None;
401-
};
402399
}
403400

404401
/// Implements Readable/Writeable for a struct storing it as a set of TLVs
@@ -480,7 +477,7 @@ macro_rules! tlv_stream {
480477
impl<'a> ::util::ser::Writeable for $nameref<'a> {
481478
fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), $crate::io::Error> {
482479
encode_tlv_stream!(writer, {
483-
$(($type, self.$field, (tlv_record, $fieldty))),*
480+
$(($type, self.$field, (option, encoding: $fieldty))),*
484481
});
485482
Ok(())
486483
}
@@ -489,10 +486,10 @@ macro_rules! tlv_stream {
489486
impl ::util::ser::Readable for $name {
490487
fn read<R: $crate::io::Read>(reader: &mut R) -> Result<Self, ::ln::msgs::DecodeError> {
491488
$(
492-
init_tlv_field_var!($field, tlv_record);
489+
init_tlv_field_var!($field, option);
493490
)*
494491
decode_tlv_stream!(reader, {
495-
$(($type, $field, (tlv_record, $fieldty))),*
492+
$(($type, $field, (option, encoding: $fieldty))),*
496493
});
497494

498495
Ok(Self {

0 commit comments

Comments
 (0)