Skip to content

Commit b02670a

Browse files
committed
Add an Event for sending revoke_and_ack messages out-of-band
1 parent 4cca933 commit b02670a

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
@@ -866,6 +866,17 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
866866
Self::do_attempt_write_data(&mut descriptor, peer);
867867
continue;
868868
},
869+
Event::SendRevokeAndACK { ref node_id, ref msg } => {
870+
log_trace!(self, "Handling SendRevokeAndACK event in peer_handler for node {} for channel {}",
871+
log_pubkey!(node_id),
872+
log_bytes!(msg.channel_id));
873+
let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, {
874+
//TODO: Do whatever we're gonna do for handling dropped messages
875+
});
876+
peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg, 133)));
877+
Self::do_attempt_write_data(&mut descriptor, peer);
878+
continue;
879+
},
869880
Event::SendShutdown { ref node_id, ref msg } => {
870881
log_trace!(self, "Handling Shutdown event in peer_handler for node {} for channel {}",
871882
log_pubkey!(node_id),

src/util/events.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ pub enum Event {
129129
/// The update messages which should be sent. ALL messages in the struct should be sent!
130130
updates: msgs::CommitmentUpdate,
131131
},
132+
/// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
133+
///
134+
/// This event is handled by PeerManager::process_events if you are using a PeerManager.
135+
SendRevokeAndACK {
136+
/// The node_id of the node which should receive this message
137+
node_id: PublicKey,
138+
/// The message which should be sent.
139+
msg: msgs::RevokeAndACK,
140+
},
132141
/// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
133142
///
134143
/// This event is handled by PeerManager::process_events if you are using a PeerManager.

0 commit comments

Comments
 (0)