]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add gossip_queries messages to wire decoding
authorbmancini55 <bmancini@gmail.com>
Wed, 21 Oct 2020 21:20:26 +0000 (17:20 -0400)
committerbmancini55 <bmancini@gmail.com>
Tue, 1 Dec 2020 22:18:24 +0000 (17:18 -0500)
To enable gossip_queries message decoding, this commit implements the
wire module's Encoding trait for each message type. It also adds these
messages to the wire module's Message enum and the read function to
enable decoding of a buffer.

lightning/src/ln/peer_handler.rs
lightning/src/ln/wire.rs

index 1e57177a0d626f32679472ebf7b60ade27b6fdaf..19585616101861697810a0f3013781c7bb52d4e9 100644 (file)
@@ -841,6 +841,21 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
                                        // TODO: forward msg along to all our other peers!
                                }
                        },
+                       wire::Message::QueryShortChannelIds(_msg) => {
+                               // TODO: handle message
+                       },
+                       wire::Message::ReplyShortChannelIdsEnd(_msg) => {
+                               // TODO: handle message
+                       },
+                       wire::Message::QueryChannelRange(_msg) => {
+                               // TODO: handle message
+                       },
+                       wire::Message::ReplyChannelRange(_msg) => {
+                               // TODO: handle message
+                       },
+                       wire::Message::GossipTimestampFilter(_msg) => {
+                               // TODO: handle message
+                       },
 
                        // Unknown messages:
                        wire::Message::Unknown(msg_type) if msg_type.is_even() => {
index 6de11ea06d88930377384feed70f5eb2b026af14..8197ce151ef9deceb8fa17591c04d642e29385d2 100644 (file)
@@ -55,6 +55,11 @@ pub enum Message {
        ChannelAnnouncement(msgs::ChannelAnnouncement),
        NodeAnnouncement(msgs::NodeAnnouncement),
        ChannelUpdate(msgs::ChannelUpdate),
+       QueryShortChannelIds(msgs::QueryShortChannelIds),
+       ReplyShortChannelIdsEnd(msgs::ReplyShortChannelIdsEnd),
+       QueryChannelRange(msgs::QueryChannelRange),
+       ReplyChannelRange(msgs::ReplyChannelRange),
+       GossipTimestampFilter(msgs::GossipTimestampFilter),
        /// A message that could not be decoded because its type is unknown.
        Unknown(MessageType),
 }
@@ -90,6 +95,11 @@ impl Message {
                        &Message::ChannelAnnouncement(ref msg) => msg.type_id(),
                        &Message::NodeAnnouncement(ref msg) => msg.type_id(),
                        &Message::ChannelUpdate(ref msg) => msg.type_id(),
+                       &Message::QueryShortChannelIds(ref msg) => msg.type_id(),
+                       &Message::ReplyShortChannelIdsEnd(ref msg) => msg.type_id(),
+                       &Message::QueryChannelRange(ref msg) => msg.type_id(),
+                       &Message::ReplyChannelRange(ref msg) => msg.type_id(),
+                       &Message::GossipTimestampFilter(ref msg) => msg.type_id(),
                        &Message::Unknown(type_id) => type_id,
                }
        }
@@ -186,6 +196,21 @@ pub fn read<R: ::std::io::Read>(buffer: &mut R) -> Result<Message, msgs::DecodeE
                msgs::ChannelUpdate::TYPE => {
                        Ok(Message::ChannelUpdate(Readable::read(buffer)?))
                },
+               msgs::QueryShortChannelIds::TYPE => {
+                       Ok(Message::QueryShortChannelIds(Readable::read(buffer)?))
+               },
+               msgs::ReplyShortChannelIdsEnd::TYPE => {
+                       Ok(Message::ReplyShortChannelIdsEnd(Readable::read(buffer)?))
+               },
+               msgs::QueryChannelRange::TYPE => {
+                       Ok(Message::QueryChannelRange(Readable::read(buffer)?))
+               },
+               msgs::ReplyChannelRange::TYPE => {
+                       Ok(Message::ReplyChannelRange(Readable::read(buffer)?))
+               }
+               msgs::GossipTimestampFilter::TYPE => {
+                       Ok(Message::GossipTimestampFilter(Readable::read(buffer)?))
+               },
                _ => {
                        Ok(Message::Unknown(MessageType(message_type)))
                },
@@ -312,6 +337,26 @@ impl Encode for msgs::ChannelUpdate {
        const TYPE: u16 = 258;
 }
 
+impl Encode for msgs::QueryShortChannelIds {
+       const TYPE: u16 = 261;
+}
+
+impl Encode for msgs::ReplyShortChannelIdsEnd {
+       const TYPE: u16 = 262;
+}
+
+impl Encode for msgs::QueryChannelRange {
+       const TYPE: u16 = 263;
+}
+
+impl Encode for msgs::ReplyChannelRange {
+       const TYPE: u16 = 264;
+}
+
+impl Encode for msgs::GossipTimestampFilter {
+       const TYPE: u16 = 265;
+}
+
 #[cfg(test)]
 mod tests {
        use super::*;