Skip to content

Commit fed764e

Browse files
committed
Add additional Clone derives
The only API change outside of additional derives is to change the inner field in `DecodeError::Io()` to an `std::io::ErrorKind` instead of an `std::io::Error`. While `std::io::Error` obviously makes more sense in context, it doesn't support Clone, and the inner error largely doesn't have a lot of value on its own.
1 parent cdee9e6 commit fed764e

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub enum ChannelMonitorUpdateErr {
174174
/// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
175175
/// corrupted.
176176
/// Contains a developer-readable error message.
177-
#[derive(Debug)]
177+
#[derive(Clone, Debug)]
178178
pub struct MonitorUpdateError(pub &'static str);
179179

180180
/// An event to be processed by the ChannelManager.

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub struct ChannelDetails {
514514
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
515515
/// Err() type describing which state the payment is in, see the description of individual enum
516516
/// states for more.
517-
#[derive(Debug)]
517+
#[derive(Clone, Debug)]
518518
pub enum PaymentSendFailure {
519519
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to
520520
/// send the payment at all. No channel state has been changed or messages sent to peers, and

lightning/src/ln/msgs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use bitcoin::hash_types::{Txid, BlockHash};
3333
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
3434

3535
use std::{cmp, fmt};
36+
use std::fmt::Debug;
3637
use std::io::Read;
3738

3839
use util::events::MessageSendEventsProvider;
@@ -44,7 +45,7 @@ use ln::channelmanager::{PaymentPreimage, PaymentHash, PaymentSecret};
4445
pub(crate) const MAX_VALUE_MSAT: u64 = 21_000_000_0000_0000_000;
4546

4647
/// An error in decoding a message or struct.
47-
#[derive(Debug)]
48+
#[derive(Clone, Debug)]
4849
pub enum DecodeError {
4950
/// A version byte specified something we don't know how to handle.
5051
/// Includes unknown realm byte in an OnionHopData packet
@@ -60,7 +61,7 @@ pub enum DecodeError {
6061
/// A length descriptor in the packet didn't describe the later data correctly
6162
BadLengthDescriptor,
6263
/// Error from std::io
63-
Io(::std::io::Error),
64+
Io(::std::io::ErrorKind),
6465
}
6566

6667
/// An init message to be sent or received from a peer
@@ -675,6 +676,7 @@ pub enum ErrorAction {
675676
}
676677

677678
/// An Err type for failure to process messages.
679+
#[derive(Clone)]
678680
pub struct LightningError {
679681
/// A human-readable message describing the error
680682
pub err: String,
@@ -950,7 +952,7 @@ impl From<::std::io::Error> for DecodeError {
950952
if e.kind() == ::std::io::ErrorKind::UnexpectedEof {
951953
DecodeError::ShortRead
952954
} else {
953-
DecodeError::Io(e)
955+
DecodeError::Io(e.kind())
954956
}
955957
}
956958
}

lightning/src/ln/peer_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub trait SocketDescriptor : cmp::Eq + hash::Hash + Clone {
9090
/// Error for PeerManager errors. If you get one of these, you must disconnect the socket and
9191
/// generate no further read_event/write_buffer_space_avail/doscket_disconnected calls for the
9292
/// descriptor.
93+
#[derive(Clone)]
9394
pub struct PeerHandleError {
9495
/// Used to indicate that we probably can't make any future connections to this peer, implying
9596
/// we should go ahead and force-close any channels we have with it.

lightning/src/routing/network_graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ where
340340
}
341341
}
342342

343-
#[derive(PartialEq, Debug)]
343+
#[derive(Clone, PartialEq, Debug)]
344344
/// Details about one direction of a channel. Received
345345
/// within a channel update.
346346
pub struct DirectionalChannelInfo {
@@ -452,7 +452,7 @@ impl Writeable for RoutingFees {
452452
}
453453
}
454454

455-
#[derive(PartialEq, Debug)]
455+
#[derive(Clone, PartialEq, Debug)]
456456
/// Information received in the latest node_announcement from this node.
457457
pub struct NodeAnnouncementInfo {
458458
/// Protocol features the node announced support for
@@ -518,7 +518,7 @@ impl Readable for NodeAnnouncementInfo {
518518
}
519519
}
520520

521-
#[derive(PartialEq)]
521+
#[derive(Clone, PartialEq)]
522522
/// Details about a node in the network, known from the network announcement.
523523
pub struct NodeInfo {
524524
/// All valid channels a node has announced

lightning/src/util/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::fmt;
1313

1414
/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
1515
/// too-high values)
16+
#[derive(Clone)]
1617
pub enum APIError {
1718
/// Indicates the API was wholly misused (see err for more). Cases where these can be returned
1819
/// are documented, but generally indicates some precondition of a function was violated.

lightning/src/util/ser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ macro_rules! impl_consensus_ser {
718718
match consensus::encode::Decodable::consensus_decode(r) {
719719
Ok(t) => Ok(t),
720720
Err(consensus::encode::Error::Io(ref e)) if e.kind() == ::std::io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead),
721-
Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e)),
721+
Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind())),
722722
Err(_) => Err(DecodeError::InvalidValue),
723723
}
724724
}

0 commit comments

Comments
 (0)