X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=110e2f336adb7e112fe5104c67a35db8aedf22e7;hb=612e2801f897d96ca22f0e82a398042ab6c21c32;hp=b8fdeb1299491dbba9f74e9d005e94168220dfbc;hpb=812f255d7c53c92656493fe103ad4129d1363a90;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index b8fdeb12..110e2f33 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -302,20 +302,20 @@ pub struct RevokeAndACK { } /// An update_fee message to be sent or received from a peer -#[derive(PartialEq)] +#[derive(PartialEq, Clone)] pub struct UpdateFee { pub(crate) channel_id: [u8; 32], pub(crate) feerate_per_kw: u32, } -#[derive(PartialEq)] +#[derive(PartialEq, Clone)] pub(crate) struct DataLossProtect { pub(crate) your_last_per_commitment_secret: [u8; 32], pub(crate) my_current_per_commitment_point: PublicKey, } /// A channel_reestablish message to be sent or received from a peer -#[derive(PartialEq)] +#[derive(PartialEq, Clone)] pub struct ChannelReestablish { pub(crate) channel_id: [u8; 32], pub(crate) next_local_commitment_number: u64, @@ -473,7 +473,7 @@ pub struct HandleError { //TODO: rename me /// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment /// transaction updates if they were pending. -#[derive(PartialEq)] +#[derive(PartialEq, Clone)] pub struct CommitmentUpdate { pub(crate) update_add_htlcs: Vec, pub(crate) update_fulfill_htlcs: Vec, @@ -511,18 +511,6 @@ pub enum HTLCFailChannelUpdate { } } -/// For events which result in both a RevokeAndACK and a CommitmentUpdate, by default they should -/// be sent in the order they appear in the return value, however sometimes the order needs to be -/// variable at runtime (eg handle_channel_reestablish needs to re-send messages in the order they -/// were originally sent). In those cases, this enum is also returned. -#[derive(Clone, PartialEq)] -pub enum RAACommitmentOrder { - /// Send the CommitmentUpdate messages first - CommitmentFirst, - /// Send the RevokeAndACK message first - RevokeAndACKFirst, -} - /// A trait to describe an object which can receive channel messages. /// /// Messages MAY be called in parallel when they originate from different their_node_ids, however @@ -556,9 +544,9 @@ pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Syn /// Handle an incoming update_fail_malformed_htlc message from the given peer. fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC) -> Result<(), HandleError>; /// Handle an incoming commitment_signed message from the given peer. - fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(RevokeAndACK, Option), HandleError>; + fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(), HandleError>; /// Handle an incoming revoke_and_ack message from the given peer. - fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result, HandleError>; + fn handle_revoke_and_ack(&self, their_node_id: &PublicKey, msg: &RevokeAndACK) -> Result<(), HandleError>; /// Handle an incoming update_fee message from the given peer. fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), HandleError>; @@ -575,9 +563,9 @@ pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Syn fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool); /// Handle a peer reconnecting, possibly generating channel_reestablish message(s). - fn peer_connected(&self, their_node_id: &PublicKey) -> Vec; + fn peer_connected(&self, their_node_id: &PublicKey); /// Handle an incoming channel_reestablish message from the given peer. - fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish) -> Result<(Option, Option, Option, RAACommitmentOrder), HandleError>; + fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish) -> Result<(), HandleError>; // Error: /// Handle an incoming error message from the given peer.