Skip to content

Commit b1fb7fd

Browse files
committed
Rename RoutingMessageHandler::sync_routing_table peer_connected
Its somewhat strange to have a trait method which is named after the intended action, rather than the action that occurred, leaving it up to the implementor what action they want to take.
1 parent c244c78 commit b1fb7fd

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ mod tests {
496496
fn handle_channel_update(&self, _msg: &ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
497497
fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) -> Vec<(ChannelAnnouncement, Option<ChannelUpdate>, Option<ChannelUpdate>)> { Vec::new() }
498498
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec<NodeAnnouncement> { Vec::new() }
499-
fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &Init) { }
499+
fn peer_connected(&self, _their_node_id: &PublicKey, _init_msg: &Init) { }
500500
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
501501
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
502502
fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: QueryChannelRange) -> Result<(), LightningError> { Ok(()) }

lightning/src/ln/msgs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ pub trait RoutingMessageHandler : MessageSendEventsProvider {
886886
/// Called when a connection is established with a peer. This can be used to
887887
/// perform routing table synchronization using a strategy defined by the
888888
/// implementor.
889-
fn sync_routing_table(&self, their_node_id: &PublicKey, init: &Init);
889+
fn peer_connected(&self, their_node_id: &PublicKey, init: &Init);
890890
/// Handles the reply of a query we initiated to learn about channels
891891
/// for a given range of blocks. We can expect to receive one or more
892892
/// replies to a single query.

lightning/src/ln/peer_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl RoutingMessageHandler for IgnoringMessageHandler {
6969
fn get_next_channel_announcements(&self, _starting_point: u64, _batch_amount: u8) ->
7070
Vec<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> { Vec::new() }
7171
fn get_next_node_announcements(&self, _starting_point: Option<&PublicKey>, _batch_amount: u8) -> Vec<msgs::NodeAnnouncement> { Vec::new() }
72-
fn sync_routing_table(&self, _their_node_id: &PublicKey, _init: &msgs::Init) {}
72+
fn peer_connected(&self, _their_node_id: &PublicKey, _init: &msgs::Init) {}
7373
fn handle_reply_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyChannelRange) -> Result<(), LightningError> { Ok(()) }
7474
fn handle_reply_short_channel_ids_end(&self, _their_node_id: &PublicKey, _msg: msgs::ReplyShortChannelIdsEnd) -> Result<(), LightningError> { Ok(()) }
7575
fn handle_query_channel_range(&self, _their_node_id: &PublicKey, _msg: msgs::QueryChannelRange) -> Result<(), LightningError> { Ok(()) }
@@ -1018,7 +1018,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
10181018
return Err(PeerHandleError{ no_connection_possible: true }.into());
10191019
}
10201020

1021-
self.message_handler.route_handler.sync_routing_table(&peer.their_node_id.unwrap(), &msg);
1021+
self.message_handler.route_handler.peer_connected(&peer.their_node_id.unwrap(), &msg);
10221022

10231023
self.message_handler.chan_handler.peer_connected(&peer.their_node_id.unwrap(), &msg);
10241024
peer.their_features = Some(msg.features);

lightning/src/routing/network_graph.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,7 @@ where C::Target: chain::Access, L::Target: Logger
395395
/// to request gossip messages for each channel. The sync is considered complete
396396
/// when the final reply_scids_end message is received, though we are not
397397
/// tracking this directly.
398-
fn sync_routing_table(&self, their_node_id: &PublicKey, init_msg: &Init) {
399-
398+
fn peer_connected(&self, their_node_id: &PublicKey, init_msg: &Init) {
400399
// We will only perform a sync with peers that support gossip_queries.
401400
if !init_msg.features.supports_gossip_queries() {
402401
return ();
@@ -2271,15 +2270,15 @@ mod tests {
22712270
// It should ignore if gossip_queries feature is not enabled
22722271
{
22732272
let init_msg = Init { features: InitFeatures::known().clear_gossip_queries() };
2274-
net_graph_msg_handler.sync_routing_table(&node_id_1, &init_msg);
2273+
net_graph_msg_handler.peer_connected(&node_id_1, &init_msg);
22752274
let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
22762275
assert_eq!(events.len(), 0);
22772276
}
22782277

22792278
// It should send a query_channel_message with the correct information
22802279
{
22812280
let init_msg = Init { features: InitFeatures::known() };
2282-
net_graph_msg_handler.sync_routing_table(&node_id_1, &init_msg);
2281+
net_graph_msg_handler.peer_connected(&node_id_1, &init_msg);
22832282
let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
22842283
assert_eq!(events.len(), 1);
22852284
match &events[0] {
@@ -2303,7 +2302,7 @@ mod tests {
23032302
for n in 1..7 {
23042303
let node_privkey = &SecretKey::from_slice(&[n; 32]).unwrap();
23052304
let node_id = PublicKey::from_secret_key(&secp_ctx, node_privkey);
2306-
net_graph_msg_handler.sync_routing_table(&node_id, &init_msg);
2305+
net_graph_msg_handler.peer_connected(&node_id, &init_msg);
23072306
let events = net_graph_msg_handler.get_and_clear_pending_msg_events();
23082307
if n <= 5 {
23092308
assert_eq!(events.len(), 1);

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
384384
Vec::new()
385385
}
386386

387-
fn sync_routing_table(&self, _their_node_id: &PublicKey, _init_msg: &msgs::Init) {}
387+
fn peer_connected(&self, _their_node_id: &PublicKey, _init_msg: &msgs::Init) {}
388388

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

0 commit comments

Comments
 (0)