X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=6939af13e22d331804529388fa3265e814209358;hb=7608483b0f5894cf2001af02248adac28bd2b269;hp=0e6c4b95ee32645d4e43a5ead08331e99d4784f6;hpb=2afd53148f42eb9b7319d3e8841578aacdc31e6e;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 0e6c4b95..6939af13 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -525,7 +525,7 @@ pub struct ChannelUpdate { pub(crate) contents: UnsignedChannelUpdate, } -/// Used to put an error message in a HandleError +/// Used to put an error message in a LightningError #[derive(Clone)] pub enum ErrorAction { /// The peer took some action which made us think they were useless. Disconnect them. @@ -543,7 +543,7 @@ pub enum ErrorAction { } /// An Err type for failure to process messages. -pub struct HandleError { //TODO: rename me +pub struct LightningError { /// A human-readable message describing the error pub err: &'static str, /// The action which should be taken against the offending peer. @@ -616,42 +616,42 @@ pub enum OptionalField { pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Sync { //Channel init: /// Handle an incoming open_channel message from the given peer. - fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &OpenChannel) -> Result<(), HandleError>; + fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &OpenChannel) -> Result<(), LightningError>; /// Handle an incoming accept_channel message from the given peer. - fn handle_accept_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &AcceptChannel) -> Result<(), HandleError>; + fn handle_accept_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &AcceptChannel) -> Result<(), LightningError>; /// Handle an incoming funding_created message from the given peer. - fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated) -> Result<(), HandleError>; + fn handle_funding_created(&self, their_node_id: &PublicKey, msg: &FundingCreated) -> Result<(), LightningError>; /// Handle an incoming funding_signed message from the given peer. - fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &FundingSigned) -> Result<(), HandleError>; + fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &FundingSigned) -> Result<(), LightningError>; /// Handle an incoming funding_locked message from the given peer. - fn handle_funding_locked(&self, their_node_id: &PublicKey, msg: &FundingLocked) -> Result<(), HandleError>; + fn handle_funding_locked(&self, their_node_id: &PublicKey, msg: &FundingLocked) -> Result<(), LightningError>; // Channl close: /// Handle an incoming shutdown message from the given peer. - fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &Shutdown) -> Result<(), HandleError>; + fn handle_shutdown(&self, their_node_id: &PublicKey, msg: &Shutdown) -> Result<(), LightningError>; /// Handle an incoming closing_signed message from the given peer. - fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned) -> Result<(), HandleError>; + fn handle_closing_signed(&self, their_node_id: &PublicKey, msg: &ClosingSigned) -> Result<(), LightningError>; // HTLC handling: /// Handle an incoming update_add_htlc message from the given peer. - fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC) -> Result<(), HandleError>; + fn handle_update_add_htlc(&self, their_node_id: &PublicKey, msg: &UpdateAddHTLC) -> Result<(), LightningError>; /// Handle an incoming update_fulfill_htlc message from the given peer. - fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC) -> Result<(), HandleError>; + fn handle_update_fulfill_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFulfillHTLC) -> Result<(), LightningError>; /// Handle an incoming update_fail_htlc message from the given peer. - fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC) -> Result<(), HandleError>; + fn handle_update_fail_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailHTLC) -> Result<(), LightningError>; /// 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>; + fn handle_update_fail_malformed_htlc(&self, their_node_id: &PublicKey, msg: &UpdateFailMalformedHTLC) -> Result<(), LightningError>; /// Handle an incoming commitment_signed message from the given peer. - fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(), HandleError>; + fn handle_commitment_signed(&self, their_node_id: &PublicKey, msg: &CommitmentSigned) -> Result<(), LightningError>; /// 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<(), LightningError>; /// Handle an incoming update_fee message from the given peer. - fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), HandleError>; + fn handle_update_fee(&self, their_node_id: &PublicKey, msg: &UpdateFee) -> Result<(), LightningError>; // Channel-to-announce: /// Handle an incoming announcement_signatures message from the given peer. - fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), HandleError>; + fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), LightningError>; // Connection loss/reestablish: /// Indicates a connection to the peer failed/an existing connection was lost. If no connection @@ -663,7 +663,7 @@ pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Syn /// Handle a peer reconnecting, possibly generating channel_reestablish message(s). 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<(), HandleError>; + fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &ChannelReestablish) -> Result<(), LightningError>; // Error: /// Handle an incoming error message from the given peer. @@ -674,13 +674,13 @@ pub trait ChannelMessageHandler : events::MessageSendEventsProvider + Send + Syn pub trait RoutingMessageHandler : Send + Sync { /// Handle an incoming node_announcement message, returning true if it should be forwarded on, /// false or returning an Err otherwise. - fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result; + fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result; /// Handle a channel_announcement message, returning true if it should be forwarded on, false /// or returning an Err otherwise. - fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result; + fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result; /// Handle an incoming channel_update message, returning true if it should be forwarded on, /// false or returning an Err otherwise. - fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result; + fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result; /// Handle some updates to the route graph that we learned due to an outbound failed payment. fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate); /// Gets a subset of the channel announcements and updates required to dump our routing table @@ -770,7 +770,7 @@ impl fmt::Display for DecodeError { } } -impl fmt::Debug for HandleError { +impl fmt::Debug for LightningError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.err) }