Skip to content

Commit 5cf6408

Browse files
Rename ser macro
We want a similar macro for reading TLV streams without a length prefix, so rename this one to disambiguate.
1 parent 3889ab7 commit 5cf6408

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

lightning/src/events/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,12 @@ pub enum Event {
768768
user_channel_id: u128,
769769
/// The reason the channel was closed.
770770
reason: ClosureReason,
771-
/// Counterparty in the closed channel.
772-
///
771+
/// Counterparty in the closed channel.
772+
///
773773
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
774774
counterparty_node_id: Option<PublicKey>,
775-
/// Channel capacity of the closing channel (sats).
776-
///
775+
/// Channel capacity of the closing channel (sats).
776+
///
777777
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
778778
channel_capacity_sats: Option<u64>,
779779
},
@@ -976,8 +976,8 @@ impl Writeable for Event {
976976
(5, outbound_amount_forwarded_msat, option),
977977
});
978978
},
979-
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
980-
ref counterparty_node_id, ref channel_capacity_sats
979+
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
980+
ref counterparty_node_id, ref channel_capacity_sats
981981
} => {
982982
9u8.write(writer)?;
983983
// `user_channel_id` used to be a single u64 value. In order to remain backwards
@@ -1312,7 +1312,7 @@ impl MaybeReadable for Event {
13121312
},
13131313
13u8 => {
13141314
let f = || {
1315-
_init_and_read_tlv_fields!(reader, {
1315+
_init_and_read_len_prefixed_tlv_fields!(reader, {
13161316
(0, payment_id, required),
13171317
(2, payment_hash, option),
13181318
(4, path, required_vec),
@@ -1371,7 +1371,7 @@ impl MaybeReadable for Event {
13711371
},
13721372
21u8 => {
13731373
let f = || {
1374-
_init_and_read_tlv_fields!(reader, {
1374+
_init_and_read_len_prefixed_tlv_fields!(reader, {
13751375
(0, payment_id, required),
13761376
(2, payment_hash, required),
13771377
(4, path, required_vec),
@@ -1387,7 +1387,7 @@ impl MaybeReadable for Event {
13871387
},
13881388
23u8 => {
13891389
let f = || {
1390-
_init_and_read_tlv_fields!(reader, {
1390+
_init_and_read_len_prefixed_tlv_fields!(reader, {
13911391
(0, payment_id, required),
13921392
(2, payment_hash, required),
13931393
(4, path, required_vec),

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ impl Writeable for CommitmentTransaction {
13561356

13571357
impl Readable for CommitmentTransaction {
13581358
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
1359-
_init_and_read_tlv_fields!(reader, {
1359+
_init_and_read_len_prefixed_tlv_fields!(reader, {
13601360
(0, commitment_number, required),
13611361
(2, to_broadcaster_value_sat, required),
13621362
(4, to_countersignatory_value_sat, required),

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7644,7 +7644,7 @@ impl Writeable for ChannelDetails {
76447644

76457645
impl Readable for ChannelDetails {
76467646
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
7647-
_init_and_read_tlv_fields!(reader, {
7647+
_init_and_read_len_prefixed_tlv_fields!(reader, {
76487648
(1, inbound_scid_alias, option),
76497649
(2, channel_id, required),
76507650
(3, channel_type, option),
@@ -7856,7 +7856,7 @@ impl Writeable for ClaimableHTLC {
78567856

78577857
impl Readable for ClaimableHTLC {
78587858
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
7859-
_init_and_read_tlv_fields!(reader, {
7859+
_init_and_read_len_prefixed_tlv_fields!(reader, {
78607860
(0, prev_hop, required),
78617861
(1, total_msat, option),
78627862
(2, value_ser, required),

lightning/src/offers/invoice_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Writeable for InvoiceError {
7070

7171
impl Readable for InvoiceError {
7272
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
73-
_init_and_read_tlv_fields!(reader, {
73+
_init_and_read_len_prefixed_tlv_fields!(reader, {
7474
(1, erroneous_field, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
7575
(3, suggested_value, (option, encoding: (Vec<u8>, WithoutLength))),
7676
(5, error, (option, encoding: (UntrustedString, WithoutLength))),

lightning/src/routing/gossip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ impl Writeable for NodeAnnouncementInfo {
11511151

11521152
impl Readable for NodeAnnouncementInfo {
11531153
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
1154-
_init_and_read_tlv_fields!(reader, {
1154+
_init_and_read_len_prefixed_tlv_fields!(reader, {
11551155
(0, features, required),
11561156
(2, last_update, required),
11571157
(4, rgb, required),
@@ -1259,7 +1259,7 @@ impl Readable for NodeInfo {
12591259
// with zero inbound fees, causing that heuristic to provide little gain. Worse, because it
12601260
// requires additional complexity and lookups during routing, it ends up being a
12611261
// performance loss. Thus, we simply ignore the old field here and no longer track it.
1262-
_init_and_read_tlv_fields!(reader, {
1262+
_init_and_read_len_prefixed_tlv_fields!(reader, {
12631263
(0, _lowest_inbound_channel_fees, option),
12641264
(2, announcement_info_wrap, upgradable_option),
12651265
(4, channels, required_vec),

lightning/src/routing/router.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl Readable for Route {
425425
cmp::min(min_final_cltv_expiry_delta, hops.last().unwrap().cltv_expiry_delta);
426426
paths.push(Path { hops, blinded_tail: None });
427427
}
428-
_init_and_read_tlv_fields!(reader, {
428+
_init_and_read_len_prefixed_tlv_fields!(reader, {
429429
(1, payment_params, (option: ReadableArgs, min_final_cltv_expiry_delta)),
430430
(2, blinded_tails, optional_vec),
431431
});
@@ -467,7 +467,7 @@ impl Writeable for RouteParameters {
467467

468468
impl Readable for RouteParameters {
469469
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
470-
_init_and_read_tlv_fields!(reader, {
470+
_init_and_read_len_prefixed_tlv_fields!(reader, {
471471
(0, payment_params, (required: ReadableArgs, 0)),
472472
(2, final_value_msat, required),
473473
(4, final_cltv_delta, option),
@@ -575,7 +575,7 @@ impl Writeable for PaymentParameters {
575575

576576
impl ReadableArgs<u32> for PaymentParameters {
577577
fn read<R: io::Read>(reader: &mut R, default_final_cltv_expiry_delta: u32) -> Result<Self, DecodeError> {
578-
_init_and_read_tlv_fields!(reader, {
578+
_init_and_read_len_prefixed_tlv_fields!(reader, {
579579
(0, payee_pubkey, option),
580580
(1, max_total_cltv_expiry_delta, (default_value, DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA)),
581581
(2, features, (option: ReadableArgs, payee_pubkey.is_some())),

lightning/src/util/ser_macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ macro_rules! _init_tlv_field_var {
797797
/// This is exported for use by other exported macros, do not use directly.
798798
#[doc(hidden)]
799799
#[macro_export]
800-
macro_rules! _init_and_read_tlv_fields {
800+
macro_rules! _init_and_read_len_prefixed_tlv_fields {
801801
($reader: ident, {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}) => {
802802
$(
803803
$crate::_init_tlv_field_var!($field, $fieldty);
@@ -867,7 +867,7 @@ macro_rules! impl_writeable_tlv_based {
867867

868868
impl $crate::util::ser::Readable for $st {
869869
fn read<R: $crate::io::Read>(reader: &mut R) -> Result<Self, $crate::ln::msgs::DecodeError> {
870-
$crate::_init_and_read_tlv_fields!(reader, {
870+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
871871
$(($type, $field, $fieldty)),*
872872
});
873873
Ok(Self {
@@ -1019,7 +1019,7 @@ macro_rules! impl_writeable_tlv_based_enum {
10191019
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
10201020
// in the same function body. Instead, we define a closure and call it.
10211021
let f = || {
1022-
$crate::_init_and_read_tlv_fields!(reader, {
1022+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
10231023
$(($type, $field, $fieldty)),*
10241024
});
10251025
Ok($st::$variant_name {
@@ -1073,7 +1073,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
10731073
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
10741074
// in the same function body. Instead, we define a closure and call it.
10751075
let f = || {
1076-
$crate::_init_and_read_tlv_fields!(reader, {
1076+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
10771077
$(($type, $field, $fieldty)),*
10781078
});
10791079
Ok(Some($st::$variant_name {

0 commit comments

Comments
 (0)