Skip to content

Commit f65eca1

Browse files
committed
Make the custom message traits cloneable as they're deep in nested structs
1 parent 25091c1 commit f65eca1

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

fuzz/src/onion_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler {
133133
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {}
134134
}
135135

136-
#[derive(Debug)]
136+
#[derive(Clone, Debug)]
137137
struct TestCustomMessage {}
138138

139139
const CUSTOM_MESSAGE_TYPE: u64 = 4242;

lightning/src/ln/wire.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ impl<T> TestEq for T {}
4545
/// A Lightning message returned by [`read`] when decoding bytes received over the wire. Each
4646
/// variant contains a message from [`msgs`] or otherwise the message type if unknown.
4747
#[allow(missing_docs)]
48-
#[derive(Debug)]
48+
#[derive(Clone, Debug)]
4949
#[cfg_attr(test, derive(PartialEq))]
50-
pub(crate) enum Message<T> where T: core::fmt::Debug + Type + TestEq {
50+
pub(crate) enum Message<T> where T: Clone + core::fmt::Debug + Type + TestEq {
5151
Init(msgs::Init),
5252
Error(msgs::ErrorMessage),
5353
Warning(msgs::WarningMessage),
@@ -419,13 +419,13 @@ pub(crate) use self::encode::Encode;
419419
/// Defines a type identifier for sending messages over the wire.
420420
///
421421
/// Messages implementing this trait specify a type and must be [`Writeable`].
422-
pub trait Type: core::fmt::Debug + Writeable {
422+
pub trait Type: core::fmt::Debug + Writeable + Clone {
423423
/// Returns the type identifying the message payload.
424424
fn type_id(&self) -> u16;
425425
}
426426

427427
#[cfg(test)]
428-
pub trait Type: core::fmt::Debug + Writeable + PartialEq {
428+
pub trait Type: core::fmt::Debug + Writeable + Clone + PartialEq {
429429
fn type_id(&self) -> u16;
430430
}
431431

@@ -435,12 +435,12 @@ impl Type for () {
435435
}
436436

437437
#[cfg(test)]
438-
impl<T: core::fmt::Debug + Writeable + PartialEq> Type for T where T: Encode {
438+
impl<T: core::fmt::Debug + Writeable + Clone + PartialEq> Type for T where T: Encode {
439439
fn type_id(&self) -> u16 { T::TYPE }
440440
}
441441

442442
#[cfg(not(test))]
443-
impl<T: core::fmt::Debug + Writeable> Type for T where T: Encode {
443+
impl<T: core::fmt::Debug + Writeable + Clone> Type for T where T: Encode {
444444
fn type_id(&self) -> u16 { T::TYPE }
445445
}
446446

@@ -786,7 +786,7 @@ mod tests {
786786
}
787787
}
788788

789-
#[derive(Eq, PartialEq, Debug)]
789+
#[derive(Clone, Eq, PartialEq, Debug)]
790790
struct TestCustomMessage {}
791791

792792
const CUSTOM_MESSAGE_TYPE : u16 = 9000;

lightning/src/onion_message/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ fn reply_path() {
670670
fn invalid_custom_message_type() {
671671
let nodes = create_nodes(2);
672672

673-
#[derive(Debug)]
673+
#[derive(Debug, Clone)]
674674
struct InvalidCustomMessage{}
675675
impl OnionMessageContents for InvalidCustomMessage {
676676
fn tlv_type(&self) -> u64 {

lightning/src/onion_message/messenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ for OnionMessenger<ES, NS, L, NL, MR, OMH, APH, DRH, CMH> where
211211
/// &custom_message_handler,
212212
/// );
213213
///
214-
/// # #[derive(Debug)]
214+
/// # #[derive(Clone, Debug)]
215215
/// # struct YourCustomMessage {}
216216
/// impl Writeable for YourCustomMessage {
217217
/// fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {

lightning/src/onion_message/packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<T: OnionMessageContents> Writeable for ParsedOnionMessageContents<T> {
187187
}
188188

189189
/// The contents of an onion message.
190-
pub trait OnionMessageContents: Writeable + core::fmt::Debug {
190+
pub trait OnionMessageContents: Writeable + core::fmt::Debug + Clone {
191191
/// Returns the TLV type identifying the message contents. MUST be >= 64.
192192
fn tlv_type(&self) -> u64;
193193

0 commit comments

Comments
 (0)