X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fmsgs.rs;h=f0f1d4890e13370f83cc3c8c633da57f7b03ce20;hb=d7b33fcd847f5480e438b2df176449d73f582090;hp=ed0b3479b78b82060ad85c49f36570f289198840;hpb=eccd527a55307b94a5c5c5df7e3ef056440e79b8;p=rust-lightning diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index ed0b3479..f0f1d489 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -357,7 +357,9 @@ pub enum ErrorAction { msg: UpdateFailHTLC }, /// The peer took some action which made us think they were useless. Disconnect them. - DisconnectPeer {}, + DisconnectPeer, + /// The peer did something harmless that we weren't able to process, just log and ignore + IgnoreError, } pub struct HandleError { //TODO: rename me @@ -386,7 +388,7 @@ pub enum HTLCFailChannelUpdate { /// A trait to describe an object which can receive channel messages. Messages MAY be called in /// paralell when they originate from different their_node_ids, however they MUST NOT be called in /// paralell when the two calls have the same their_node_id. -pub trait ChannelMessageHandler : events::EventsProvider { +pub trait ChannelMessageHandler : events::EventsProvider + Send + Sync { //Channel init: fn handle_open_channel(&self, their_node_id: &PublicKey, msg: &OpenChannel) -> Result; fn handle_accept_channel(&self, their_node_id: &PublicKey, msg: &AcceptChannel) -> Result<(), HandleError>; @@ -419,7 +421,7 @@ pub trait ChannelMessageHandler : events::EventsProvider { fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool); } -pub trait RoutingMessageHandler { +pub trait RoutingMessageHandler : Send + Sync { fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<(), HandleError>; /// Handle a channel_announcement message, returning true if it should be forwarded on, false /// or returning an Err otherwise. @@ -506,7 +508,7 @@ macro_rules! secp_signature { impl MsgDecodable for LocalFeatures { fn decode(v: &[u8]) -> Result { - if v.len() < 3 { return Err(DecodeError::WrongLength); } + if v.len() < 2 { return Err(DecodeError::WrongLength); } let len = byte_utils::slice_to_be16(&v[0..2]) as usize; if v.len() < len + 2 { return Err(DecodeError::WrongLength); } let mut flags = Vec::with_capacity(len); @@ -528,7 +530,7 @@ impl MsgEncodable for LocalFeatures { impl MsgDecodable for GlobalFeatures { fn decode(v: &[u8]) -> Result { - if v.len() < 3 { return Err(DecodeError::WrongLength); } + if v.len() < 2 { return Err(DecodeError::WrongLength); } let len = byte_utils::slice_to_be16(&v[0..2]) as usize; if v.len() < len + 2 { return Err(DecodeError::WrongLength); } let mut flags = Vec::with_capacity(len);