Rename ser macro

We want a similar macro for reading TLV streams without a length prefix, so
rename this one to disambiguate.
This commit is contained in:
Valentine Wallace 2023-08-14 19:54:31 -04:00
parent 9777485ed7
commit 4a30d9e78a
No known key found for this signature in database
GPG key ID: FD3E106A2CE099B4
7 changed files with 22 additions and 22 deletions

View file

@ -821,12 +821,12 @@ pub enum Event {
user_channel_id: u128,
/// The reason the channel was closed.
reason: ClosureReason,
/// Counterparty in the closed channel.
///
/// Counterparty in the closed channel.
///
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
counterparty_node_id: Option<PublicKey>,
/// Channel capacity of the closing channel (sats).
///
/// Channel capacity of the closing channel (sats).
///
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
channel_capacity_sats: Option<u64>,
},
@ -1030,8 +1030,8 @@ impl Writeable for Event {
(5, outbound_amount_forwarded_msat, option),
});
},
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
ref counterparty_node_id, ref channel_capacity_sats
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
ref counterparty_node_id, ref channel_capacity_sats
} => {
9u8.write(writer)?;
// `user_channel_id` used to be a single u64 value. In order to remain backwards
@ -1368,7 +1368,7 @@ impl MaybeReadable for Event {
},
13u8 => {
let f = || {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payment_id, required),
(2, payment_hash, option),
(4, path, required_vec),
@ -1433,7 +1433,7 @@ impl MaybeReadable for Event {
},
21u8 => {
let f = || {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payment_id, required),
(2, payment_hash, required),
(4, path, required_vec),
@ -1449,7 +1449,7 @@ impl MaybeReadable for Event {
},
23u8 => {
let f = || {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payment_id, required),
(2, payment_hash, required),
(4, path, required_vec),

View file

@ -1356,7 +1356,7 @@ impl Writeable for CommitmentTransaction {
impl Readable for CommitmentTransaction {
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, commitment_number, required),
(2, to_broadcaster_value_sat, required),
(4, to_countersignatory_value_sat, required),

View file

@ -7809,7 +7809,7 @@ impl Writeable for ChannelDetails {
impl Readable for ChannelDetails {
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(1, inbound_scid_alias, option),
(2, channel_id, required),
(3, channel_type, option),
@ -8023,7 +8023,7 @@ impl Writeable for ClaimableHTLC {
impl Readable for ClaimableHTLC {
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, prev_hop, required),
(1, total_msat, option),
(2, value_ser, required),

View file

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

View file

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

View file

@ -425,7 +425,7 @@ impl Readable for Route {
cmp::min(min_final_cltv_expiry_delta, hops.last().unwrap().cltv_expiry_delta);
paths.push(Path { hops, blinded_tail: None });
}
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(1, payment_params, (option: ReadableArgs, min_final_cltv_expiry_delta)),
(2, blinded_tails, optional_vec),
});
@ -467,7 +467,7 @@ impl Writeable for RouteParameters {
impl Readable for RouteParameters {
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payment_params, (required: ReadableArgs, 0)),
(2, final_value_msat, required),
(4, final_cltv_delta, option),
@ -575,7 +575,7 @@ impl Writeable for PaymentParameters {
impl ReadableArgs<u32> for PaymentParameters {
fn read<R: io::Read>(reader: &mut R, default_final_cltv_expiry_delta: u32) -> Result<Self, DecodeError> {
_init_and_read_tlv_fields!(reader, {
_init_and_read_len_prefixed_tlv_fields!(reader, {
(0, payee_pubkey, option),
(1, max_total_cltv_expiry_delta, (default_value, DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA)),
(2, features, (option: ReadableArgs, payee_pubkey.is_some())),

View file

@ -794,7 +794,7 @@ macro_rules! _init_tlv_field_var {
/// This is exported for use by other exported macros, do not use directly.
#[doc(hidden)]
#[macro_export]
macro_rules! _init_and_read_tlv_fields {
macro_rules! _init_and_read_len_prefixed_tlv_fields {
($reader: ident, {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}) => {
$(
$crate::_init_tlv_field_var!($field, $fieldty);
@ -863,7 +863,7 @@ macro_rules! impl_writeable_tlv_based {
impl $crate::util::ser::Readable for $st {
fn read<R: $crate::io::Read>(reader: &mut R) -> Result<Self, $crate::ln::msgs::DecodeError> {
$crate::_init_and_read_tlv_fields!(reader, {
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
$(($type, $field, $fieldty)),*
});
Ok(Self {
@ -1015,7 +1015,7 @@ macro_rules! impl_writeable_tlv_based_enum {
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
// in the same function body. Instead, we define a closure and call it.
let f = || {
$crate::_init_and_read_tlv_fields!(reader, {
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
$(($type, $field, $fieldty)),*
});
Ok($st::$variant_name {
@ -1069,7 +1069,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
// in the same function body. Instead, we define a closure and call it.
let f = || {
$crate::_init_and_read_tlv_fields!(reader, {
$crate::_init_and_read_len_prefixed_tlv_fields!(reader, {
$(($type, $field, $fieldty)),*
});
Ok(Some($st::$variant_name {