fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) -> Vec<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> { Vec::new() }
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec<NodeAnnouncement> { Vec::new() }
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool { false }
- fn sync_routing_table(&self, _their_node_id: &PublicKey) { }
+ fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &Init) { }
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
use chain;
use chain::Access;
use ln::features::{ChannelFeatures, NodeFeatures};
-use ln::msgs::{DecodeError, ErrorAction, LightningError, RoutingMessageHandler, NetAddress, MAX_VALUE_MSAT};
+use ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMessageHandler, NetAddress, MAX_VALUE_MSAT};
use ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, OptionalField};
use ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, ReplyShortChannelIdsEnd};
use ln::msgs;
/// gossip messages for each channel. The sync is considered complete when
/// the final reply_scids_end message is received, though we are not
/// tracking this directly.
- fn sync_routing_table(&self, their_node_id: &PublicKey) {
+ fn sync_routing_table(&self, their_node_id: &PublicKey, init_msg: &Init) {
+ if !init_msg.features.supports_gossip_queries() {
+ return ();
+ }
let first_blocknum = 0;
let number_of_blocks = 0xffffffff;
log_debug!(self.logger, "Sending query_channel_range peer={}, first_blocknum={}, number_of_blocks={}", log_pubkey!(their_node_id), first_blocknum, number_of_blocks);
#[cfg(test)]
mod tests {
use chain;
- use ln::features::{ChannelFeatures, NodeFeatures};
+ use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
use routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
- use ln::msgs::{OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
+ use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate, HTLCFailChannelUpdate,
ReplyChannelRange, ReplyShortChannelIdsEnd, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
use util::test_utils;
let chain_hash = genesis_block(Network::Testnet).header.block_hash();
let first_blocknum = 0;
let number_of_blocks = 0xffff_ffff;
- net_graph_msg_handler.sync_routing_table(&node_id_1);
+
+ // It should ignore if gossip_queries feature is not enabled
+ {
+ let init_msg = Init { features: InitFeatures::known().clear_gossip_queries() };
+ net_graph_msg_handler.sync_routing_table(&node_id_1, &init_msg);
+ let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 0);
+ }
// It should send a query_channel_message with the correct information
- let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
- assert_eq!(events.len(), 1);
- match &events[0] {
- MessageSendEvent::SendChannelRangeQuery{ node_id, msg } => {
- assert_eq!(node_id, &node_id_1);
- assert_eq!(msg.chain_hash, chain_hash);
- assert_eq!(msg.first_blocknum, first_blocknum);
- assert_eq!(msg.number_of_blocks, number_of_blocks);
- },
- _ => panic!("Expected MessageSendEvent::SendChannelRangeQuery")
- };
+ {
+ let init_msg = Init { features: InitFeatures::known() };
+ net_graph_msg_handler.sync_routing_table(&node_id_1, &init_msg);
+ let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 1);
+ match &events[0] {
+ MessageSendEvent::SendChannelRangeQuery{ node_id, msg } => {
+ assert_eq!(node_id, &node_id_1);
+ assert_eq!(msg.chain_hash, chain_hash);
+ assert_eq!(msg.first_blocknum, first_blocknum);
+ assert_eq!(msg.number_of_blocks, number_of_blocks);
+ },
+ _ => panic!("Expected MessageSendEvent::SendChannelRangeQuery")
+ };
+ }
}
#[test]