Skip to content

Commit f1abd13

Browse files
committed
improved minor changes
1 parent b87dbb5 commit f1abd13

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

lightning/src/offers/invoice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ impl InvoiceContents {
10021002
}
10031003
}
10041004

1005-
pub(crate) fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef {
1005+
fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef {
10061006
let (payer, offer, invoice_request) = match self {
10071007
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.as_tlv_stream(),
10081008
InvoiceContents::ForRefund { refund, .. } => refund.as_tlv_stream(),

lightning/src/offers/invoice_request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ impl InvoiceRequestContents {
731731
.map(|payer_note| PrintableString(payer_note.as_str()))
732732
}
733733

734-
pub(crate) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
734+
pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
735735
let (payer, offer, mut invoice_request) = self.inner.as_tlv_stream();
736736
invoice_request.payer_id = Some(&self.payer_id);
737737
(payer, offer, invoice_request)
@@ -747,7 +747,7 @@ impl InvoiceRequestContentsWithoutPayerId {
747747
self.chain.unwrap_or_else(|| self.offer.implied_chain())
748748
}
749749

750-
pub(crate) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
750+
pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
751751
let payer = PayerTlvStreamRef {
752752
metadata: self.payer.0.as_bytes(),
753753
};

lightning/src/onion_message/messenger.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ use crate::prelude::*;
7070
/// # use std::sync::Arc;
7171
/// # struct FakeLogger;
7272
/// # impl Logger for FakeLogger {
73-
/// # fn log(&self, record: &Record) {
74-
/// # println!("{:?}" , record);
75-
/// # }
73+
/// # fn log(&self, record: &Record) { println!("{:?}" , record); }
7674
/// # }
7775
/// # struct FakeMessageRouter {}
7876
/// # impl MessageRouter for FakeMessageRouter {
@@ -519,7 +517,7 @@ where
519517
&self, path: OnionMessagePath, contents: T, reply_path: Option<BlindedPath>
520518
) -> Result<(), SendError> {
521519

522-
log_trace!(self.logger, "Sending onion message: {}", message);
520+
log_trace!(self.logger, "Sending onion message: {:?}", message);
523521

524522
let (introduction_node_id, onion_msg) = create_onion_message(
525523
&self.entropy_source, &self.node_signer, &self.secp_ctx,
@@ -575,17 +573,7 @@ where
575573
},
576574
};
577575

578-
log_trace!(self.logger, "Sending onion message {}", log_suffix);
579-
match &response {
580-
OnionMessageContents::Offers(ref offers_msg) => {
581-
log_trace!(self.logger, "Respoding to onion message {:?} with path_id {:02x?}", offers_msg , path_id);
582-
}
583-
OnionMessageContents::Custom(ref custom_msg) => {
584-
log_trace!(self.logger, "Respoding to onion message {} with path_id {:02x?}", custom_msg.tlv_type() , path_id);
585-
}
586-
};
587-
log_trace!(self.logger , "Responding to onion message {} with path_id {:02x?}", response , path_id);
588-
log_trace!(self.logger, "Responding to onion message {} with path_id {:02x?}", response , path_id);
576+
log_trace!(self.logger, "Responding to onion message {:?} with path_id {:02x?}", response, path_id);
589577

590578
if let Err(e) = self.send_onion_message(path, contents, reply_path) {
591579
log_trace!(self.logger, "Failed sending onion message {}: {:?}", log_suffix, e);
@@ -646,7 +634,8 @@ where
646634
Ok((Payload::Receive::<<<CMH as Deref>::Target as CustomOnionMessageHandler>::CustomMessage> {
647635
message, control_tlvs: ReceiveControlTlvs::Unblinded(ReceiveTlvs { path_id }), reply_path,
648636
}, None)) => {
649-
log_trace!(self.logger,"Received an onion message {} with path_id {:02x?} and {} reply_path", message,
637+
log_trace!(self.logger,
638+
"Received an onion message {:?} with path_id {:02x?} and {} reply_path", message,
650639
path_id, if reply_path.is_some() { "a" } else { "no" });
651640

652641
match message {

lightning/src/onion_message/offers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//! Message handling for BOLT 12 Offers.
1111
1212
use core::convert::TryFrom;
13+
use core::fmt;
1314
use crate::io::{self, Read};
1415
use crate::ln::msgs::DecodeError;
1516
use crate::offers::invoice_error::InvoiceError;
@@ -22,7 +23,6 @@ use crate::util::logger::Logger;
2223
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
2324

2425
use crate::prelude::*;
25-
use core::{fmt};
2626

2727
// TLV record types for the `onionmsg_tlv` TLV stream as defined in BOLT 4.
2828
const INVOICE_REQUEST_TLV_TYPE: u64 = 64;
@@ -97,16 +97,16 @@ impl fmt::Debug for OffersMessage {
9797
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9898
match self {
9999
OffersMessage::InvoiceRequest(message) => {
100-
write!(f, "InvoiceRequest: {:?}", message.as_tlv_stream())
100+
write!(f , "{:?}", message.as_tlv_stream())
101101
}
102102
OffersMessage::Invoice(message) => {
103-
write!(f, "Invoice: {:?}", message.as_tlv_stream())
103+
write!(f, "{:?}", message.as_tlv_stream())
104104
}
105105
OffersMessage::InvoiceError(message) => {
106-
write!(f, "InvoiceError: {:?}", message)
106+
write!(f, "{:?}", message)
107107
}
108108
}
109-
}
109+
}
110110
}
111111

112112
impl OnionMessageContents for OffersMessage {

lightning/src/onion_message/packet.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,10 @@ pub(super) enum Payload<T: OnionMessageContents> {
114114
}
115115
}
116116

117-
/// The contents of an [`OnionMessage`] as read from the wire.
118-
///
119-
/// [`OnionMessage`]: crate::ln::msgs::OnionMessage
120-
#[derive(Debug)]
121-
pub enum ParsedOnionMessageContents<T: OnionMessageContents> {
117+
// #[derive(Debug)]
118+
/// The contents of an onion message. In the context of offers, this would be the invoice, invoice
119+
/// request, or invoice error.
120+
pub enum OnionMessageContents<T: CustomOnionMessageContents> {
122121
/// A message related to BOLT 12 Offers.
123122
Offers(OffersMessage),
124123
/// A custom onion message specified by the user.
@@ -137,7 +136,7 @@ impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
137136
}
138137
}
139138

140-
impl<T: CustomOnionMessageContents> fmt::Display for OnionMessageContents<T> {
139+
impl<T: CustomOnionMessageContents> fmt::Debug for OnionMessageContents<T> {
141140
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142141
match self {
143142
OnionMessageContents::Offers(ref msg) => {

0 commit comments

Comments
 (0)