Skip to content

Commit 46d856d

Browse files
committed
Call all of BaseMessageHandler's methods on the send-only handler
In 9db37f2 we introduced a `send_only_message_handler` which was intended to be used to send messages to peers. However, when we did so we forgot to add calls to its `peer_connected`, `peer_disconnected`, `provided_node_features`, and `provided_init_features` methods. Here we add those methods, updating the comment somewhat to avoid implying that they won't be called.
1 parent 62ce76e commit 46d856d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ where
571571
/// [`IgnoringMessageHandler`].
572572
pub custom_message_handler: CustomM,
573573

574-
/// A message handler which only allows sending messages. This should generally be a
574+
/// A message handler which can be used to send messages. This should generally be a
575575
/// [`ChainMonitor`].
576576
///
577577
/// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
@@ -1363,6 +1363,7 @@ where
13631363
| self.message_handler.route_handler.provided_init_features(their_node_id)
13641364
| self.message_handler.onion_message_handler.provided_init_features(their_node_id)
13651365
| self.message_handler.custom_message_handler.provided_init_features(their_node_id)
1366+
| self.message_handler.send_only_message_handler.provided_init_features(their_node_id)
13661367
}
13671368

13681369
/// Indicates a new outbound connection has been established to a node with the given `node_id`
@@ -2165,6 +2166,19 @@ where
21652166
self.message_handler.onion_message_handler.peer_disconnected(their_node_id);
21662167
return Err(PeerHandleError {}.into());
21672168
}
2169+
let sends_handler = &self.message_handler.send_only_message_handler;
2170+
if let Err(()) = sends_handler.peer_connected(their_node_id, &msg, inbound) {
2171+
log_debug!(
2172+
logger,
2173+
"Sending-Only Message Handler decided we couldn't communicate with peer {}",
2174+
log_pubkey!(their_node_id)
2175+
);
2176+
self.message_handler.route_handler.peer_disconnected(their_node_id);
2177+
self.message_handler.chan_handler.peer_disconnected(their_node_id);
2178+
self.message_handler.onion_message_handler.peer_disconnected(their_node_id);
2179+
self.message_handler.custom_message_handler.peer_disconnected(their_node_id);
2180+
return Err(PeerHandleError {}.into());
2181+
}
21682182

21692183
peer_lock.awaiting_pong_timer_tick_intervals = 0;
21702184
peer_lock.their_features = Some(msg.features);
@@ -3370,6 +3384,7 @@ where
33703384
self.message_handler.chan_handler.peer_disconnected(node_id);
33713385
self.message_handler.onion_message_handler.peer_disconnected(node_id);
33723386
self.message_handler.custom_message_handler.peer_disconnected(node_id);
3387+
self.message_handler.send_only_message_handler.peer_disconnected(node_id);
33733388
}
33743389
descriptor.disconnect_socket();
33753390
}
@@ -3402,6 +3417,7 @@ where
34023417
self.message_handler.chan_handler.peer_disconnected(node_id);
34033418
self.message_handler.onion_message_handler.peer_disconnected(node_id);
34043419
self.message_handler.custom_message_handler.peer_disconnected(node_id);
3420+
self.message_handler.send_only_message_handler.peer_disconnected(node_id);
34053421
}
34063422
},
34073423
};
@@ -3587,7 +3603,8 @@ where
35873603
let features = self.message_handler.chan_handler.provided_node_features()
35883604
| self.message_handler.route_handler.provided_node_features()
35893605
| self.message_handler.onion_message_handler.provided_node_features()
3590-
| self.message_handler.custom_message_handler.provided_node_features();
3606+
| self.message_handler.custom_message_handler.provided_node_features()
3607+
| self.message_handler.send_only_message_handler.provided_node_features();
35913608
let announcement = msgs::UnsignedNodeAnnouncement {
35923609
features,
35933610
timestamp: self.last_node_announcement_serial.fetch_add(1, Ordering::AcqRel),

0 commit comments

Comments
 (0)