@@ -157,9 +157,10 @@ pub(crate) type IngressReceiver = mpsc::Receiver<IngressEvent>;
157
157
158
158
type NodeRecordSender = OneshotSender < Vec < NodeRecord > > ;
159
159
160
- /// The Discv4 frontend
160
+ /// The Discv4 frontend.
161
161
///
162
- /// This communicates with the [`Discv4Service`] by sending commands over a channel.
162
+ /// This is a cloneable type that communicates with the [`Discv4Service`] by sending commands over a
163
+ /// shared channel.
163
164
///
164
165
/// See also [`Discv4::spawn`]
165
166
#[ derive( Debug , Clone ) ]
@@ -174,11 +175,10 @@ pub struct Discv4 {
174
175
node_record : Arc < Mutex < NodeRecord > > ,
175
176
}
176
177
177
- // === impl Discv4 ===
178
-
179
178
impl Discv4 {
180
- /// Same as [`Self::bind`] but also spawns the service onto a new task,
181
- /// [`Discv4Service::spawn()`]
179
+ /// Same as [`Self::bind`] but also spawns the service onto a new task.
180
+ ///
181
+ /// See also: [`Discv4Service::spawn()`]
182
182
pub async fn spawn (
183
183
local_address : SocketAddr ,
184
184
local_enr : NodeRecord ,
@@ -421,6 +421,15 @@ impl Discv4 {
421
421
///
422
422
/// This is a [Stream] to handles incoming and outgoing discv4 messages and emits updates via:
423
423
/// [`Discv4Service::update_stream`].
424
+ ///
425
+ /// This type maintains the discv Kademlia routing table and is responsible for performing lookups.
426
+ ///
427
+ /// ## Lookups
428
+ ///
429
+ /// See also [Recursive Lookups](https://github.com/ethereum/devp2p/blob/master/discv4.md#recursive-lookup).
430
+ /// Lookups are either triggered periodically or performaned on demand: [`Discv4::lookup`]
431
+ /// Newly discovered nodes are emitted as [`DiscoveryUpdate::Added`] event to all subscribers:
432
+ /// [`Discv4Service::update_stream`].
424
433
#[ must_use = "Stream does nothing unless polled" ]
425
434
pub struct Discv4Service {
426
435
/// Local address of the UDP socket.
@@ -694,7 +703,7 @@ impl Discv4Service {
694
703
695
704
/// Spawns this services onto a new task
696
705
///
697
- /// Note: requires a running runtime
706
+ /// Note: requires a running tokio runtime
698
707
pub fn spawn ( mut self ) -> JoinHandle < ( ) > {
699
708
tokio:: task:: spawn ( async move {
700
709
self . bootstrap ( ) ;
0 commit comments