X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpeer_handler.rs;h=2a026821f8adf91a9f0d2ba9bfdacbc861e1db48;hb=17ec697f8f09d608f6a3d2703ed4f4409773b4bf;hp=bfa3a45de903ed31d244846afea17c7afdde7b78;hpb=e6aaf7c72dac650d4351a0d3e4fe4c8e9ab37911;p=rust-lightning diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index bfa3a45d..2a026821 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -12,8 +12,8 @@ //! Instead of actually servicing sockets ourselves we require that you implement the //! SocketDescriptor interface and use that to receive actions which you should perform on the //! socket, and call into PeerManager with bytes read from the socket. The PeerManager will then -//! call into the provided message handlers (probably a ChannelManager and NetGraphmsgHandler) with messages -//! they should handle, and encoding/sending response messages. +//! call into the provided message handlers (probably a ChannelManager and P2PGossipSync) with +//! messages they should handle, and encoding/sending response messages. use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey}; @@ -25,10 +25,10 @@ use util::ser::{VecWriter, Writeable, Writer}; use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep}; use ln::wire; use ln::wire::Encode; +use routing::gossip::{NetworkGraph, P2PGossipSync}; use util::atomic_counter::AtomicCounter; use util::events::{MessageSendEvent, MessageSendEventsProvider}; use util::logger::Logger; -use routing::network_graph::{NetworkGraph, NetGraphMsgHandler}; use prelude::*; use io; @@ -151,7 +151,7 @@ impl ChannelMessageHandler for ErroringMessageHandler { fn handle_funding_signed(&self, their_node_id: &PublicKey, msg: &msgs::FundingSigned) { ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id); } - fn handle_funding_locked(&self, their_node_id: &PublicKey, msg: &msgs::FundingLocked) { + fn handle_channel_ready(&self, their_node_id: &PublicKey, msg: &msgs::ChannelReady) { ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id); } fn handle_shutdown(&self, their_node_id: &PublicKey, _their_features: &InitFeatures, msg: &msgs::Shutdown) { @@ -208,10 +208,9 @@ pub struct MessageHandler where /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager pub chan_handler: CM, /// A message handler which handles messages updating our knowledge of the network channel - /// graph. Usually this is just a [`NetGraphMsgHandler`] object or an - /// [`IgnoringMessageHandler`]. + /// graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. /// - /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + /// [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync pub route_handler: RM, } @@ -258,8 +257,13 @@ pub trait SocketDescriptor : cmp::Eq + hash::Hash + Clone { /// descriptor. #[derive(Clone)] pub struct PeerHandleError { - /// Used to indicate that we probably can't make any future connections to this peer, implying - /// we should go ahead and force-close any channels we have with it. + /// Used to indicate that we probably can't make any future connections to this peer (e.g. + /// because we required features that our peer was missing, or vice versa). + /// + /// While LDK's [`ChannelManager`] will not do it automatically, you likely wish to force-close + /// any channels with this peer or check for new versions of LDK. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager pub no_connection_possible: bool, } impl fmt::Debug for PeerHandleError { @@ -383,7 +387,7 @@ impl Peer { /// issues such as overly long function definitions. /// /// (C-not exported) as Arcs don't make sense in bindings -pub type SimpleArcPeerManager = PeerManager>, Arc, Arc, Arc>>, Arc, Arc>; +pub type SimpleArcPeerManager = PeerManager>, Arc>>, Arc, Arc>>, Arc, Arc>; /// SimpleRefPeerManager is a type alias for a PeerManager reference, and is the reference /// counterpart to the SimpleArcPeerManager type alias. Use this type by default when you don't @@ -393,7 +397,7 @@ pub type SimpleArcPeerManager = PeerManager = PeerManager, &'e NetGraphMsgHandler<&'g NetworkGraph, &'h C, &'f L>, &'f L, IgnoringMessageHandler>; +pub type SimpleRefPeerManager<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, SD, M, T, F, C, L> = PeerManager, &'e P2PGossipSync<&'g NetworkGraph<&'f L>, &'h C, &'f L>, &'f L, IgnoringMessageHandler>; /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls /// socket events into messages which it passes on to its [`MessageHandler`]. @@ -1204,8 +1208,8 @@ impl P wire::Message::FundingSigned(msg) => { self.message_handler.chan_handler.handle_funding_signed(&their_node_id, &msg); }, - wire::Message::FundingLocked(msg) => { - self.message_handler.chan_handler.handle_funding_locked(&their_node_id, &msg); + wire::Message::ChannelReady(msg) => { + self.message_handler.chan_handler.handle_channel_ready(&their_node_id, &msg); }, wire::Message::Shutdown(msg) => { @@ -1481,8 +1485,8 @@ impl P log_bytes!(msg.channel_id)); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg); }, - MessageSendEvent::SendFundingLocked { ref node_id, ref msg } => { - log_debug!(self.logger, "Handling SendFundingLocked event in peer_handler for node {} for channel {}", + MessageSendEvent::SendChannelReady { ref node_id, ref msg } => { + log_debug!(self.logger, "Handling SendChannelReady event in peer_handler for node {} for channel {}", log_pubkey!(node_id), log_bytes!(msg.channel_id)); self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);