Skip to content

Commit 4a30d9e

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 9777485 commit 4a30d9e

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
@@ -821,12 +821,12 @@ pub enum Event {
821821
user_channel_id: u128,
822822
/// The reason the channel was closed.
823823
reason: ClosureReason,
824-
/// Counterparty in the closed channel.
825-
///
824+
/// Counterparty in the closed channel.
825+
///
826826
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
827827
counterparty_node_id: Option<PublicKey>,
828-
/// Channel capacity of the closing channel (sats).
829-
///
828+
/// Channel capacity of the closing channel (sats).
829+
///
830830
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
831831
channel_capacity_sats: Option<u64>,
832832
},
@@ -1030,8 +1030,8 @@ impl Writeable for Event {
10301030
(5, outbound_amount_forwarded_msat, option),
10311031
});
10321032
},
1033-
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
1034-
ref counterparty_node_id, ref channel_capacity_sats
1033+
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
1034+
ref counterparty_node_id, ref channel_capacity_sats
10351035
} => {
10361036
9u8.write(writer)?;
10371037
// `user_channel_id` used to be a single u64 value. In order to remain backwards
@@ -1368,7 +1368,7 @@ impl MaybeReadable for Event {
13681368
},
13691369
13u8 => {
13701370
let f = || {
1371-
_init_and_read_tlv_fields!(reader, {
1371+
_init_and_read_len_prefixed_tlv_fields!(reader, {
13721372
(0, payment_id, required),
13731373
(2, payment_hash, option),
13741374
(4, path, required_vec),
@@ -1433,7 +1433,7 @@ impl MaybeReadable for Event {
14331433
},
14341434
21u8 => {
14351435
let f = || {
1436-
_init_and_read_tlv_fields!(reader, {
1436+
_init_and_read_len_prefixed_tlv_fields!(reader, {
14371437
(0, payment_id, required),
14381438
(2, payment_hash, required),
14391439
(4, path, required_vec),
@@ -1449,7 +1449,7 @@ impl MaybeReadable for Event {
14491449
},
14501450
23u8 => {
14511451
let f = || {
1452-
_init_and_read_tlv_fields!(reader, {
1452+
_init_and_read_len_prefixed_tlv_fields!(reader, {
14531453
(0, payment_id, required),
14541454
(2, payment_hash, required),
14551455
(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
@@ -7809,7 +7809,7 @@ impl Writeable for ChannelDetails {
78097809

78107810
impl Readable for ChannelDetails {
78117811
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
7812-
_init_and_read_tlv_fields!(reader, {
7812+
_init_and_read_len_prefixed_tlv_fields!(reader, {
78137813
(1, inbound_scid_alias, option),
78147814
(2, channel_id, required),
78157815
(3, channel_type, option),
@@ -8023,7 +8023,7 @@ impl Writeable for ClaimableHTLC {
80238023

80248024
impl Readable for ClaimableHTLC {
80258025
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
8026-
_init_and_read_tlv_fields!(reader, {
8026+
_init_and_read_len_prefixed_tlv_fields!(reader, {
80278027
(0, prev_hop, required),
80288028
(1, total_msat, option),
80298029
(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
@@ -794,7 +794,7 @@ macro_rules! _init_tlv_field_var {
794794
/// This is exported for use by other exported macros, do not use directly.
795795
#[doc(hidden)]
796796
#[macro_export]
797-
macro_rules! _init_and_read_tlv_fields {
797+
macro_rules! _init_and_read_len_prefixed_tlv_fields {
798798
($reader: ident, {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}) => {
799799
$(
800800
$crate::_init_tlv_field_var!($field, $fieldty);
@@ -863,7 +863,7 @@ macro_rules! impl_writeable_tlv_based {
863863

864864
impl $crate::util::ser::Readable for $st {
865865
fn read<R: $crate::io::Read>(reader: &mut R) -> Result<Self, $crate::ln::msgs::DecodeError> {
866-
$crate::_init_and_read_tlv_fields!(reader, {
866+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
867867
$(($type, $field, $fieldty)),*
868868
});
869869
Ok(Self {
@@ -1015,7 +1015,7 @@ macro_rules! impl_writeable_tlv_based_enum {
10151015
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
10161016
// in the same function body. Instead, we define a closure and call it.
10171017
let f = || {
1018-
$crate::_init_and_read_tlv_fields!(reader, {
1018+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
10191019
$(($type, $field, $fieldty)),*
10201020
});
10211021
Ok($st::$variant_name {
@@ -1069,7 +1069,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
10691069
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
10701070
// in the same function body. Instead, we define a closure and call it.
10711071
let f = || {
1072-
$crate::_init_and_read_tlv_fields!(reader, {
1072+
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
10731073
$(($type, $field, $fieldty)),*
10741074
});
10751075
Ok(Some($st::$variant_name {

0 commit comments

Comments
 (0)