@@ -160,7 +160,7 @@ pub struct MessageHandler<CM: Deref, RM: Deref> where
160
160
CM :: Target : ChannelMessageHandler ,
161
161
RM :: Target : RoutingMessageHandler {
162
162
/// A message handler which handles messages specific to channels. Usually this is just a
163
- /// [`ChannelManager`] object or a [`ErroringMessageHandler`].
163
+ /// [`ChannelManager`] object or an [`ErroringMessageHandler`].
164
164
///
165
165
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
166
166
pub chan_handler : CM ,
@@ -191,20 +191,22 @@ pub trait SocketDescriptor : cmp::Eq + hash::Hash + Clone {
191
191
/// Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be
192
192
/// called and further write attempts may occur until that time.
193
193
///
194
- /// If the returned size is smaller than data.len(), a
194
+ /// If the returned size is smaller than ` data.len()` , a
195
195
/// [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be
196
- /// written. Additionally, until a send_data event completes fully, no further
196
+ /// written. Additionally, until a ` send_data` event completes fully, no further
197
197
/// [`PeerManager::read_event`] calls should be made for the same peer! Because this is to
198
198
/// prevent denial-of-service issues, you should not read or buffer any data from the socket
199
199
/// until then.
200
200
///
201
201
/// If a [`PeerManager::read_event`] call on this descriptor had previously returned true
202
202
/// (indicating that read events should be paused to prevent DoS in the send buffer),
203
- /// resume_read may be set indicating that read events on this descriptor should resume. A
204
- /// resume_read of false does *not* imply on its own that further read events should be paused .
203
+ /// ` resume_read` may be set indicating that read events on this descriptor should resume. A
204
+ /// ` resume_read` of false carries no meaning, and should not cause any action .
205
205
fn send_data ( & mut self , data : & [ u8 ] , resume_read : bool ) -> usize ;
206
206
/// Disconnect the socket pointed to by this SocketDescriptor.
207
- /// No [`PeerManager::socket_disconnected`] call need be generated as a result of this call.
207
+ ///
208
+ /// You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this
209
+ /// call (doing so is a noop).
208
210
fn disconnect_socket ( & mut self ) ;
209
211
}
210
212
@@ -319,16 +321,16 @@ pub type SimpleArcPeerManager<SD, M, T, F, C, L> = PeerManager<SD, Arc<SimpleArc
319
321
pub type SimpleRefPeerManager < ' a , ' b , ' c , ' d , ' e , ' f , ' g , SD , M , T , F , C , L > = PeerManager < SD , SimpleRefChannelManager < ' a , ' b , ' c , ' d , ' e , M , T , F , L > , & ' e NetGraphMsgHandler < & ' g C , & ' f L > , & ' f L > ;
320
322
321
323
/// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
322
- /// socket events into messages which it passes on to its MessageHandlers .
324
+ /// socket events into messages which it passes on to its [`MessageHandler`] .
323
325
///
324
326
/// Locks are taken internally, so you must never assume that reentrancy from a
325
327
/// [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock.
326
328
///
327
329
/// Calls to [`read_event`] will decode relevant messages and pass them to the
328
330
/// [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of
329
- /// parallelism in Rust-Lightning is parallelism in calls to [`read_event`]. Note, however, that
330
- /// calls to any [`PeerManager`] functions related to the same connection must occur only in
331
- /// serial, making new calls only after previous ones have returned.
331
+ /// parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any
332
+ /// [`PeerManager`] functions related to the same connection must occur only in serial, making new
333
+ /// calls only after previous ones have returned.
332
334
///
333
335
/// Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager
334
336
/// a SimpleRefPeerManager, for conciseness. See their documentation for more details, but
@@ -626,11 +628,11 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
626
628
///
627
629
/// May return an Err to indicate that the connection should be closed.
628
630
///
629
- /// Will most likely call [`send_data`] on the descriptor passed in (or the descriptor handed
630
- /// into new_*\_connection) before returning. Thus, be very careful with reentrancy issues! The
631
- /// invariants around calling [`write_buffer_space_avail`] in case a write did not fully
632
- /// complete must still hold - be ready to call `[write_buffer_space_avail`] again if a write
633
- /// call generated here isn't sufficient!
631
+ /// May call [`send_data`] on the descriptor passed in (or another provided descriptor) before
632
+ /// returning. Thus, be very careful with reentrancy issues! The invariants around calling
633
+ /// [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be
634
+ /// ready to call `[write_buffer_space_avail`] again if a write call generated here isnt'
635
+ /// sufficient!
634
636
///
635
637
/// [`send_data`]: SocketDescriptor::send_data
636
638
/// [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail
@@ -656,11 +658,12 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
656
658
/// May return an Err to indicate that the connection should be closed.
657
659
///
658
660
/// Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity.
659
- /// Thus, however, you almost certainly want to call [`process_events`] after any read_event
660
- /// to generate [`send_data`] calls to handle responses.
661
+ /// Thus, however, you should call [`process_events`] after any ` read_event` to generate
662
+ /// [`send_data`] calls to handle responses.
661
663
///
662
- /// If Ok(true) is returned, further read_events should not be triggered until a [`send_data`]
663
- /// call on this descriptor has resume_read set (preventing DoS issues in the send buffer).
664
+ /// If `Ok(true)` is returned, further read_events should not be triggered until a
665
+ /// [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the
666
+ /// send buffer).
664
667
///
665
668
/// [`send_data`]: SocketDescriptor::send_data
666
669
/// [`process_events`]: PeerManager::process_events
@@ -1113,8 +1116,8 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
1113
1116
/// response messages as well as messages generated by calls to handler functions directly (eg
1114
1117
/// functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]).
1115
1118
///
1116
- /// Will most likely call [`send_data`] on descriptors previously provided to
1117
- /// new_*\_connection. Thus, be very careful with reentrancy issues!
1119
+ /// May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy
1120
+ /// issues!
1118
1121
///
1119
1122
/// [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1120
1123
/// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
@@ -1357,7 +1360,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
1357
1360
1358
1361
/// Disconnect a peer given its node id.
1359
1362
///
1360
- /// Set no_connection_possible to true to prevent any further connection with this peer,
1363
+ /// Set ` no_connection_possible` to true to prevent any further connection with this peer,
1361
1364
/// force-closing any channels we have with it.
1362
1365
///
1363
1366
/// If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the
@@ -1375,10 +1378,11 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
1375
1378
}
1376
1379
1377
1380
/// This function should be called roughly once every 30 seconds.
1378
- /// It will send pings to each peer and disconnect those which did not respond to the last round of pings.
1381
+ /// It will send pings to each peer and disconnect those which did not respond to the last
1382
+ /// round of pings.
1379
1383
///
1380
- /// Will most likely call [`send_data`] all descriptors previously provided to
1381
- /// new_*\_connection. Thus, be very careful with reentrancy issues!
1384
+ /// May call [`send_data`] all [`SocketDescriptor`]s. Thus, be very careful with reentrancy
1385
+ /// issues!
1382
1386
///
1383
1387
/// [`send_data`]: SocketDescriptor::send_data
1384
1388
pub fn timer_tick_occurred ( & self ) {
0 commit comments