Skip to content

Commit 34f8c39

Browse files
ser_macros: Document behavior of upgradable_* variants
1 parent 5d0ee86 commit 34f8c39

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,19 @@ macro_rules! _decode_tlv {
292292
($reader: expr, $field: ident, option) => {{
293293
$field = Some($crate::util::ser::Readable::read(&mut $reader)?);
294294
}};
295+
// `upgradable_required` indicates we're reading a required TLV that may have been upgraded
296+
// without backwards compat. We'll error if the field is missing, and return `Ok(None)` if the
297+
// field is present but we can no longer understand it.
298+
// Note that this variant can only be used within a `MaybeReadable` read.
295299
($reader: expr, $field: ident, upgradable_required) => {{
296300
$field = match $crate::util::ser::MaybeReadable::read(&mut $reader)? {
297301
Some(res) => res,
298302
_ => return Ok(None)
299303
};
300304
}};
305+
// `upgradable_option` indicates we're reading an Option-al TLV that may have been upgraded
306+
// without backwards compat. $field will be None if the TLV is missing or if the field is present
307+
// but we can no longer understand it.
301308
($reader: expr, $field: ident, upgradable_option) => {{
302309
$field = $crate::util::ser::MaybeReadable::read(&mut $reader)?;
303310
}};

0 commit comments

Comments
 (0)