Skip to content

Commit 2f42adf

Browse files
can't believe I had parsing misktakes all this time
1 parent fb76f6d commit 2f42adf

File tree

10 files changed

+287
-271
lines changed

10 files changed

+287
-271
lines changed

dht/src/dht.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn resume_identity(conn: &mut SqliteConnection, public_ip: Ipv4Addr) -> Result<N
123123
let id_in_base64 =
124124
prev_id.expect("if the public ip of last session matches this session, id should have been set");
125125
let id = base64_dec(id_in_base64);
126-
Ok(NodeId::from_bytes_unchecked(&*id))
126+
Ok(NodeId::from_bytes(&*id))
127127
} else {
128128
// IP changed, generate new ID
129129
let id = random_idv4(&public_ip, rand::rng().random::<u8>());
@@ -365,38 +365,4 @@ mod tests {
365365
drop(dht_eventloop);
366366
Ok(())
367367
}
368-
369-
#[tokio::test(flavor = "multi_thread")]
370-
async fn find_peers() -> color_eyre::Result<()> {
371-
todo!("Proabaly just stick it inside of the json_rpc server instead of doing it here");
372-
// TEST_INIT.call_once(set_up_tracing);
373-
//
374-
// let external_ip = public_ip::addr_v4().await.unwrap();
375-
//
376-
// let dht = DhtV4::with_stable_id(
377-
// SocketAddrV4::from_str("0.0.0.0:44444").unwrap(),
378-
// external_ip,
379-
// vec![
380-
// // dht.tansmissionbt.com
381-
// "87.98.162.88:6881".parse().unwrap(),
382-
// // router.utorrent.com
383-
// "67.215.246.10:6881".parse().unwrap(),
384-
// // router.bittorrent.com, ironically that this almost never responds
385-
// "82.221.103.244:6881".parse().unwrap(),
386-
// // dht.aelitis.com
387-
// "174.129.43.152:6881".parse().unwrap(),
388-
// ],
389-
// )
390-
// .await?;
391-
//
392-
// // XXX: get_peers design is problematic, impl has been replaced with todo!(), see the
393-
// // comment on the function itself for more info.
394-
// //
395-
// let info_hash = InfoHash::from_hex_str("233b78ca585fe0a8c9e8eb4bda03f52e8b6f554b");
396-
//
397-
// let handle = dht.handle();
398-
// let peers = handle.get_peers(info_hash).await?;
399-
// info!("peers {peers:?}");
400-
// Ok(())
401-
}
402368
}

dht/src/dht/router.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,14 @@ impl Router {
317317
}
318318
}
319319

320+
// TODO: introduce an inflight table to only allow one refresh operation per bucket at each
321+
// time
320322
async fn refresh_bucket(&self, i: i32) {
321323
let mut conn = self.conn();
322324
let problematics = self.replacement_queue(i, &mut conn);
323325

324326
let tasks = problematics.into_iter().map(|n| async move {
325-
let id = NodeId::from_bytes_unchecked(&*n.id);
327+
let id = NodeId::from_bytes(&*n.id);
326328
let ip: Ipv4Addr = n.ip_addr.parse().unwrap();
327329
let endpoint = SocketAddrV4::new(ip, n.port as u16);
328330
let target = NodeInfo::new(id, endpoint);

0 commit comments

Comments
 (0)