mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
implement Stream for Discovery (#5370)
This commit is contained in:
@ -14,11 +14,12 @@ use secp256k1::SecretKey;
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap, VecDeque},
|
||||
net::{IpAddr, SocketAddr},
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
task::{Context, Poll},
|
||||
task::{ready, Context, Poll},
|
||||
};
|
||||
use tokio::{sync::mpsc, task::JoinHandle};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
use tokio_stream::{wrappers::ReceiverStream, Stream};
|
||||
|
||||
/// An abstraction over the configured discovery protocol.
|
||||
///
|
||||
@ -216,6 +217,14 @@ impl Discovery {
|
||||
}
|
||||
}
|
||||
|
||||
impl Stream for Discovery {
|
||||
type Item = DiscoveryEvent;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
Poll::Ready(Some(ready!(self.get_mut().poll(cx))))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl Discovery {
|
||||
/// Returns a Discovery instance that does nothing and is intended for testing purposes.
|
||||
|
||||
Reference in New Issue
Block a user