From: Matt Corallo Date: Tue, 20 Oct 2020 18:01:22 +0000 (-0400) Subject: derive(Clone) for several pub simple data structs. X-Git-Tag: v0.0.12~4^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=d73711104482c78d501a5ea47a39b466585ca34d;p=rust-lightning derive(Clone) for several pub simple data structs. There is no reason not to and Clone can be useful especially in the bindings context. --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index bb8d8c32d..c3382caae 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -179,7 +179,7 @@ pub enum ChannelMonitorUpdateErr { pub struct MonitorUpdateError(pub &'static str); /// An event to be processed by the ChannelManager. -#[derive(PartialEq)] +#[derive(Clone, PartialEq)] pub enum MonitorEvent { /// A monitor event containing an HTLCUpdate. HTLCEvent(HTLCUpdate), diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 540155a3a..7b7d511d6 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -318,6 +318,7 @@ impl_writeable!(TxCreationKeys, 33*6, /// in the signer. /// The pre-calculated keys are an optimization, because ChannelKeys has enough /// information to re-derive them. +#[derive(PartialEq, Clone)] pub struct PreCalculatedTxCreationKeys(TxCreationKeys); impl PreCalculatedTxCreationKeys { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index a884b5f72..d47eba053 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -475,6 +475,7 @@ const CHECK_CLTV_EXPIRY_SANITY: u32 = CLTV_EXPIRY_DELTA as u32 - LATENCY_GRACE_P const CHECK_CLTV_EXPIRY_SANITY_2: u32 = CLTV_EXPIRY_DELTA as u32 - LATENCY_GRACE_PERIOD_BLOCKS - 2*CLTV_CLAIM_BUFFER; /// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels +#[derive(Clone)] pub struct ChannelDetails { /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, /// thereafter this is the txid of the funding transaction xor the funding transaction output). diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 16ba08629..f57cf0fd1 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -64,6 +64,7 @@ pub enum DecodeError { } /// An init message to be sent or received from a peer +#[derive(Clone)] pub struct Init { #[cfg(not(feature = "fuzztarget"))] pub(crate) features: InitFeatures, @@ -84,6 +85,7 @@ pub struct ErrorMessage { } /// A ping message to be sent or received from a peer +#[derive(Clone)] pub struct Ping { /// The desired response length pub ponglen: u16, @@ -93,6 +95,7 @@ pub struct Ping { } /// A pong message to be sent or received from a peer +#[derive(Clone)] pub struct Pong { /// The pong packet size. /// This field is not sent on the wire. byteslen zeros are sent. diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 56beb2ea0..64a08e732 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -113,6 +113,7 @@ impl Readable for Route { } /// A channel descriptor which provides a last-hop route to get_route +#[derive(Clone)] pub struct RouteHint { /// The node_id of the non-target end of the route pub src_node_id: PublicKey, diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index 60191b886..3eeacdc73 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -31,7 +31,7 @@ use std::time::Duration; /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never /// written as it makes no sense to respond to it after reconnecting to peers). -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum Event { /// Used to indicate that the client should generate a funding transaction with the given /// parameters and then call ChannelManager::funding_transaction_generated.