Refactor DHT a bit
This commit is contained in:
parent
48f4c0a8b7
commit
ace11186ef
6 changed files with 119 additions and 96 deletions
|
|
@ -10,9 +10,10 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
let info_hash = Id20::from_str("64a980abe6e448226bb930ba061592e44c3781a1").unwrap();
|
||||
let dht = Dht::new().await.context("error initializing DHT")?;
|
||||
let mut stream = dht.get_peers(info_hash).await;
|
||||
let mut stream = dht.get_peers(info_hash).await?;
|
||||
let mut seen = HashSet::new();
|
||||
while let Some(peer) = stream.next().await {
|
||||
let peer = peer.context("error reading peer stream")?;
|
||||
if seen.insert(peer) {
|
||||
log::info!("peer found: {}", peer)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue