From: Matt Corallo Date: Wed, 17 Oct 2018 15:35:26 +0000 (-0400) Subject: Add an Event for sending revoke_and_ack messages out-of-band X-Git-Tag: v0.0.12~289^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=b02670a920f8edaf7b41eed09b1d9cfe01f08a5a;p=rust-lightning Add an Event for sending revoke_and_ack messages out-of-band --- diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index b629e7fa6..94cdef9e4 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -866,6 +866,17 @@ impl PeerManager { Self::do_attempt_write_data(&mut descriptor, peer); continue; }, + Event::SendRevokeAndACK { ref node_id, ref msg } => { + log_trace!(self, "Handling SendRevokeAndACK event in peer_handler for node {} for channel {}", + log_pubkey!(node_id), + log_bytes!(msg.channel_id)); + let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, { + //TODO: Do whatever we're gonna do for handling dropped messages + }); + peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg, 133))); + Self::do_attempt_write_data(&mut descriptor, peer); + continue; + }, Event::SendShutdown { ref node_id, ref msg } => { log_trace!(self, "Handling Shutdown event in peer_handler for node {} for channel {}", log_pubkey!(node_id), diff --git a/src/util/events.rs b/src/util/events.rs index 51417c63c..e11e4e82c 100644 --- a/src/util/events.rs +++ b/src/util/events.rs @@ -129,6 +129,15 @@ pub enum Event { /// The update messages which should be sent. ALL messages in the struct should be sent! updates: msgs::CommitmentUpdate, }, + /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + /// + /// This event is handled by PeerManager::process_events if you are using a PeerManager. + SendRevokeAndACK { + /// The node_id of the node which should receive this message + node_id: PublicKey, + /// The message which should be sent. + msg: msgs::RevokeAndACK, + }, /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. /// /// This event is handled by PeerManager::process_events if you are using a PeerManager.