use chain::Access;
use ln::features::{ChannelFeatures, NodeFeatures};
use ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMessageHandler, NetAddress, MAX_VALUE_MSAT};
-use ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, OptionalField};
+use ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, OptionalField, GossipTimestampFilter};
use ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, ReplyShortChannelIdsEnd};
use ln::msgs;
use util::ser::{Writeable, Readable, Writer};
return ();
}
+ // Send a gossip_timestamp_filter to enable gossip message receipt. Note that we have to
+ // use a "all timestamps" filter as sending the current timestamp would result in missing
+ // gossip messages that are simply sent late. We could calculate the intended filter time
+ // by looking at the current time and subtracting two weeks (before which we'll reject
+ // messages), but there's not a lot of reason to bother - our peers should be discarding
+ // the same messages.
+ let mut pending_events = self.pending_events.lock().unwrap();
+ pending_events.push(MessageSendEvent::SendGossipTimestampFilter {
+ node_id: their_node_id.clone(),
+ msg: GossipTimestampFilter {
+ chain_hash: self.network_graph.genesis_hash,
+ first_timestamp: 0,
+ timestamp_range: u32::max_value(),
+ },
+ });
+
// Check if we need to perform a full synchronization with this peer
if !self.should_request_full_sync(&their_node_id) {
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);
- let mut pending_events = self.pending_events.lock().unwrap();
pending_events.push(MessageSendEvent::SendChannelRangeQuery {
node_id: their_node_id.clone(),
msg: QueryChannelRange {
let init_msg = Init { features: InitFeatures::known() };
net_graph_msg_handler.peer_connected(&node_id_1, &init_msg);
let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
- assert_eq!(events.len(), 1);
+ assert_eq!(events.len(), 2);
match &events[0] {
+ MessageSendEvent::SendGossipTimestampFilter{ node_id, msg } => {
+ assert_eq!(node_id, &node_id_1);
+ assert_eq!(msg.chain_hash, chain_hash);
+ assert_eq!(msg.first_timestamp, 0);
+ assert_eq!(msg.timestamp_range, u32::max_value());
+ },
+ _ => panic!("Expected MessageSendEvent::SendChannelRangeQuery")
+ };
+ match &events[1] {
MessageSendEvent::SendChannelRangeQuery{ node_id, msg } => {
assert_eq!(node_id, &node_id_1);
assert_eq!(msg.chain_hash, chain_hash);
net_graph_msg_handler.peer_connected(&node_id, &init_msg);
let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
if n <= 5 {
- assert_eq!(events.len(), 1);
+ assert_eq!(events.len(), 2);
} else {
- assert_eq!(events.len(), 0);
+ // Even after the we stop sending the explicit query, we should still send a
+ // gossip_timestamp_filter on each new connection.
+ assert_eq!(events.len(), 1);
}
}