]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add send message events for gossip_queries
authorbmancini55 <bmancini@gmail.com>
Thu, 22 Oct 2020 12:47:24 +0000 (08:47 -0400)
committerbmancini55 <bmancini@gmail.com>
Wed, 9 Dec 2020 20:02:22 +0000 (15:02 -0500)
This change enables initiating gossip queries with a peer using the
SendMessageEvent enum. Specifically we add an event for sending
query_channel_range to discover the existance of channels and an event
for sending query_short_channel_ids to request routing gossip messages
for a set of channels. These events are handled inside the process_events
method of PeerManager which sends the serialized message to the peer.

lightning/src/ln/channelmanager.rs
lightning/src/ln/peer_handler.rs
lightning/src/util/events.rs

index 0f5e7f8ad63736dcf5f567f3cd5a9af920a57735..c39eef3ea477a9d7558b69629601c4be14d6dbfc 100644 (file)
@@ -3404,6 +3404,8 @@ impl<ChanSigner: ChannelKeys, M: Deref + Sync + Send, T: Deref + Sync + Send, K:
                                        &events::MessageSendEvent::BroadcastChannelUpdate { .. } => true,
                                        &events::MessageSendEvent::HandleError { ref node_id, .. } => node_id != counterparty_node_id,
                                        &events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => true,
+                                       &events::MessageSendEvent::SendChannelRangeQuery { .. } => false,
+                                       &events::MessageSendEvent::SendShortIdsQuery { .. } => false,
                                }
                        });
                }
index 19585616101861697810a0f3013781c7bb52d4e9..b318e50318285497c8bbb0bfb797664c92c6ac1a 100644 (file)
@@ -1131,6 +1131,16 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
                                                                self.do_attempt_write_data(&mut descriptor, peer);
                                                        },
                                                }
+                                       },
+                                       MessageSendEvent::SendChannelRangeQuery { ref node_id, ref msg } => {
+                                               let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, {});
+                                               peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg)));
+                                               self.do_attempt_write_data(&mut descriptor, peer);
+                                       },
+                                       MessageSendEvent::SendShortIdsQuery { ref node_id, ref msg } => {
+                                               let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, {});
+                                               peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg)));
+                                               self.do_attempt_write_data(&mut descriptor, peer);
                                        }
                                }
                        }
index 3eeacdc732cb12969f0cddd69aa329745dce5297..6f6f32daeab18226313872d1b5ae15fbd3bfa038 100644 (file)
@@ -346,7 +346,22 @@ pub enum MessageSendEvent {
        PaymentFailureNetworkUpdate {
                /// The channel/node update which should be sent to NetGraphMsgHandler
                update: msgs::HTLCFailChannelUpdate,
-       }
+       },
+       /// Query a peer for channels with funding transaction UTXOs in a block range.
+       SendChannelRangeQuery {
+               /// The node_id of this message recipient
+               node_id: PublicKey,
+               /// The query_channel_range which should be sent.
+               msg: msgs::QueryChannelRange,
+       },
+       /// Request routing gossip messages from a peer for a list of channels identified by
+       /// their short_channel_ids.
+       SendShortIdsQuery {
+               /// The node_id of this message recipient
+               node_id: PublicKey,
+               /// The query_short_channel_ids which should be sent.
+               msg: msgs::QueryShortChannelIds,
+       },
 }
 
 /// A trait indicating an object may generate message send events