Skip to content

Commit b164682

Browse files
committed
Add an Event for sending revoke_and_ack messages out-of-band
1 parent 42fb58a commit b164682

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/ln/peer_handler.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,17 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
869869
Self::do_attempt_write_data(&mut descriptor, peer);
870870
continue;
871871
},
872+
Event::SendRevokeAndACK { ref node_id, ref msg } => {
873+
log_trace!(self, "Handling SendRevokeAndACK event in peer_handler for node {} for channel {}",
874+
log_pubkey!(node_id),
875+
log_bytes!(msg.channel_id));
876+
let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, {
877+
//TODO: Do whatever we're gonna do for handling dropped messages
878+
});
879+
peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg, 133)));
880+
Self::do_attempt_write_data(&mut descriptor, peer);
881+
continue;
882+
},
872883
Event::SendShutdown { ref node_id, ref msg } => {
873884
log_trace!(self, "Handling Shutdown event in peer_handler for node {} for channel {}",
874885
log_pubkey!(node_id),

src/util/events.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ pub enum Event {
125125
/// The update messages which should be sent. ALL messages in the struct should be sent!
126126
updates: msgs::CommitmentUpdate,
127127
},
128+
/// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
129+
///
130+
/// This event is handled by PeerManager::process_events if you are using a PeerManager.
131+
SendRevokeAndACK {
132+
/// The node_id of the node which should receive this message
133+
node_id: PublicKey,
134+
/// The message which should be sent.
135+
msg: msgs::RevokeAndACK,
136+
},
128137
/// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
129138
///
130139
/// This event is handled by PeerManager::process_events if you are using a PeerManager.

0 commit comments

Comments
 (0)