Skip to content

Commit e0bb63b

Browse files
committed
Remove should_request_full_sync from RoutingMessageHandler
This method was used to set the initial_routing_sync flag when sending an outbound Init message to a peer. Since we are now relying on gossip_queries instead of initial_routing_sync, synchronization can be fully encapsulate into RoutingMessageHandler via sync_routing_table. This commit removes should_request_full_sync from the trait RoutingMessageHandler. The implementation is still used in NetGraphMsgHandler and has been converted into a private method instead of a trait function.
1 parent e742894 commit e0bb63b

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ mod tests {
535535
fn handle_htlc_fail_channel_update(&self, _update: &HTLCFailChannelUpdate) { }
536536
fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) -> Vec<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> { Vec::new() }
537537
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec<NodeAnnouncement> { Vec::new() }
538-
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool { false }
539538
fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &Init) { }
540539
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
541540
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }

lightning/src/ln/msgs.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,6 @@ pub trait RoutingMessageHandler : Send + Sync + events::MessageSendEventsProvide
831831
/// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
832832
/// If None is provided for starting_point, we start at the first node.
833833
fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>, batch_amount: u8) -> Vec<NodeAnnouncement>;
834-
/// Returns whether a full sync should be requested from a peer.
835-
fn should_request_full_sync(&self, node_id: &PublicKey) -> bool;
836834
/// Initiates routing gossip sync by querying a peer to discover channels
837835
/// and their associated routing gossip messages. This method will use a
838836
/// sync strategy defined by the implementor.

lightning/src/routing/network_graph.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
105105
pub fn read_locked_graph<'a>(&'a self) -> LockedNetworkGraph<'a> {
106106
LockedNetworkGraph(self.network_graph.read().unwrap())
107107
}
108+
109+
/// Returns true when a full routing table sync should be performed with a peer.
110+
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
111+
//TODO: Determine whether to request a full sync based on the network map.
112+
const FULL_SYNCS_TO_REQUEST: usize = 5;
113+
if self.full_syncs_requested.load(Ordering::Acquire) < FULL_SYNCS_TO_REQUEST {
114+
self.full_syncs_requested.fetch_add(1, Ordering::AcqRel);
115+
true
116+
} else {
117+
false
118+
}
119+
}
108120
}
109121

110122
impl<'a> LockedNetworkGraph<'a> {
@@ -207,17 +219,6 @@ impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for N
207219
result
208220
}
209221

210-
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
211-
//TODO: Determine whether to request a full sync based on the network map.
212-
const FULL_SYNCS_TO_REQUEST: usize = 5;
213-
if self.full_syncs_requested.load(Ordering::Acquire) < FULL_SYNCS_TO_REQUEST {
214-
self.full_syncs_requested.fetch_add(1, Ordering::AcqRel);
215-
true
216-
} else {
217-
false
218-
}
219-
}
220-
221222
/// Initiates a stateless sync of routing gossip information with a peer
222223
/// using gossip_queries. The default strategy used by this implementation
223224
/// is to sync the full block range with several peers.

lightning/src/util/test_utils.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
316316
Vec::new()
317317
}
318318

319-
fn should_request_full_sync(&self, _node_id: &PublicKey) -> bool {
320-
self.request_full_sync.load(Ordering::Acquire)
321-
}
322-
323319
fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &msgs::Init) {}
324320

325321
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), msgs::LightningError> {

0 commit comments

Comments
 (0)