Skip to content

Commit 76d207a

Browse files
committed
chore: update iroh
1 parent a8922db commit 76d207a

File tree

10 files changed

+1276
-1063
lines changed

10 files changed

+1276
-1063
lines changed

Cargo.lock

Lines changed: 1251 additions & 1031 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ data-encoding = "2.7"
5555
directories = "5"
5656
divan = "0.1.18"
5757
duct = "*"
58-
ed25519-dalek = "2.1.1"
58+
ed25519-dalek = "^3.0.0-pre.1"
5959
futures = "0.3.31"
6060
futures-lite = "2.6.1"
6161
bytes = "*"
6262
listenfd = "1.0.2"
6363
futures-util = "*"
64-
iroh = { version = "0.92.0", default-features = false }
65-
iroh-base = { version = "0.92.0", default-features = false }
64+
iroh = { version = "0.93.2", default-features = false }
65+
iroh-base = { version = "0.93.2", default-features = false }
6666
iroh-io = "0.6.0"
6767
itertools = "0.13.0"
6868
jotdown = "0.7.0"
@@ -71,7 +71,7 @@ proptest = "1.6.0"
7171
maud = "*"
7272
tempfile = "3.14.0"
7373
test-log = { version = "0.2.16", features = ["trace"] }
74-
rand = "0.8"
74+
rand = "0.9"
7575
redb = "2.3.0"
7676
redb-bincode = "0.3.0"
7777
rostra-core = { path = "crates/rostra-core" }

crates/rostra-client-db/src/tx_ops.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
22

33
use ids::{IdsFollowersRecord, IdsUnfollowedRecord};
44
use itertools::Itertools as _;
5-
use rand::{Rng as _, thread_rng};
5+
use rand::Rng as _;
66
use redb::StorageError;
77
use redb_bincode::{ReadableTable, Table};
88
use rostra_core::event::{
@@ -94,7 +94,7 @@ impl Database {
9494
.map(|g| g.value())
9595
{
9696
Some(prev_missing) => {
97-
// if the missing was marked as deleted, we'll record it
97+
// If the missing was marked as deleted, we'll record it.
9898
(
9999
true,
100100
if let Some(deleted_by) = prev_missing.deleted_by {
@@ -107,7 +107,7 @@ impl Database {
107107
)
108108
}
109109
_ => {
110-
// since nothing was expecting this event yet, it must be a "head"
110+
// Since nothing was expecting this event yet, it must be a "head".
111111
events_heads_table.insert(&(author, event_id), &EventsHeadsTableRecord)?;
112112
(false, false)
113113
}
@@ -153,18 +153,18 @@ impl Database {
153153
});
154154
}
155155
} else {
156-
// we do not have this parent yet, so we mark it as missing
156+
// We do not have this parent yet, so we mark it as missing
157157
events_missing_table.insert(
158158
&(author, parent_id),
159159
&EventsMissingRecord {
160-
// potentially mark that the missing event was already deleted
160+
// Potentially mark that the missing event was already deleted.
161161
deleted_by: (event.is_delete_parent_aux_content_set() && parent_is_aux)
162162
.then_some(event_id),
163163
},
164164
)?;
165165
missing_parents.push(parent_id);
166166
}
167-
// if the event was considered a "head", it shouldn't as it has a child
167+
// If the event was considered a "head", it shouldn't as it has a child.
168168
events_heads_table.remove(&(author, parent_id))?;
169169
}
170170

@@ -225,7 +225,7 @@ impl Database {
225225
return Ok(true);
226226
}
227227
EventContentState::Invalid(_) | EventContentState::Present(_) => {
228-
// go ahead and mark as pruned
228+
// Go ahead and mark as pruned
229229
}
230230
}
231231
}
@@ -396,7 +396,7 @@ impl Database {
396396
) -> DbResult<IdSelfAccountRecord> {
397397
let id_self_record = IdSelfAccountRecord {
398398
rostra_id: self_id,
399-
iroh_secret: thread_rng().r#gen(),
399+
iroh_secret: rand::rng().random(),
400400
};
401401
let _ = id_self_table.insert(&(), &id_self_record)?;
402402
Ok(id_self_record)
@@ -438,7 +438,7 @@ impl Database {
438438
let before_pivot = (ShortEventId::ZERO)..(pivot);
439439
let after_pivot = (pivot)..=(ShortEventId::MAX);
440440

441-
Ok(Some(if thread_rng().r#gen() {
441+
Ok(Some(if rand::rng().random() {
442442
match get_first_in_range(events_self_table, after_pivot)? {
443443
Some(k) => k,
444444
_ => match get_last_in_range(events_self_table, before_pivot)? {

crates/rostra-client/src/client.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use std::sync::{Arc, Weak};
1111
use std::time::Duration;
1212

1313
use backon::Retryable as _;
14+
use iroh::NodeAddr;
1415
use iroh::discovery::ConcurrentDiscovery;
1516
use iroh::discovery::dns::DnsDiscovery;
1617
use iroh::discovery::pkarr::PkarrPublisher;
17-
use iroh::{NodeAddr, Watcher as _};
1818
use itertools::Itertools as _;
1919
use rostra_client_db::{Database, DbResult, IdsFolloweesRecord, IdsFollowersRecord};
2020
use rostra_core::event::{
@@ -358,7 +358,7 @@ impl Client {
358358
use iroh::{Endpoint, SecretKey};
359359
let secret_key = iroh_secret
360360
.into()
361-
.unwrap_or_else(|| SecretKey::generate(&mut rand::thread_rng()));
361+
.unwrap_or_else(|| SecretKey::generate(&mut rand::rng()));
362362

363363
let discovery = ConcurrentDiscovery::from_services(vec![
364364
Box::new(PkarrPublisher::n0_dns().build(secret_key.clone())),
@@ -448,9 +448,7 @@ impl Client {
448448
}
449449
}
450450

451-
Ok(sanitize_node_addr(
452-
self.endpoint.node_addr().initialized().await,
453-
))
451+
Ok(sanitize_node_addr(self.endpoint.node_addr()))
454452
}
455453

456454
pub fn self_head_subscribe(&self) -> watch::Receiver<Option<ShortEventId>> {

crates/rostra-client/src/task/head_merger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl HeadMerger {
3737
// To avoid two active nodes merging heads together at the same time, producing
3838
// more heads, that require more merging, etc., we just sleep a random period of
3939
// time here, which should be enough to propagate and eventually desynchronize.
40-
let rand_secs = rand::thread_rng().gen_range(0..60);
40+
let rand_secs = rand::rng().random_range(0..60);
4141
tokio::time::sleep(Duration::from_secs(rand_secs)).await;
4242

4343
let Ok(client) = self.client.client_ref() else {

crates/rostra-client/src/task/pkarr_id_publisher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl PkarrIdPublisher {
181181
trace!(target: LOG_TARGET, "Detect other peer alive, waiting");
182182
failures_count = 0;
183183
}
184-
let secs = rand::thread_rng().gen_range(1..10);
184+
let secs = rand::rng().random_range(1..10);
185185
tokio::time::sleep(Duration::from_secs(secs)).await;
186186
}
187187
}

crates/rostra-core/src/event/ed25519.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use ed25519_dalek::ed25519::signature::SignerMut as _;
2-
use ed25519_dalek::{SignatureError, VerifyingKey};
1+
use ed25519_dalek::{SignatureError, Signer, VerifyingKey};
32

43
use super::{Event, EventSignature, SignedEvent};
54
use crate::bincode::STD_BINCODE_CONFIG;

crates/rostra-core/src/id/ed25519.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use ed25519_dalek::{SigningKey, VerifyingKey};
2-
use rand::rngs::OsRng;
32

43
use super::{RostraId, RostraIdSecretKey};
54

65
impl RostraIdSecretKey {
76
pub fn generate() -> Self {
8-
let mut csprng = OsRng;
9-
SigningKey::generate(&mut csprng).into()
7+
SigningKey::generate(&mut rand::rng()).into()
108
}
119

1210
pub fn id(self) -> RostraId {

crates/rostra-core/src/rand.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use rand::Rng as _;
2-
use rand::rngs::OsRng;
32

43
use super::ShortEventId;
54

6-
impl rand::distributions::Distribution<ShortEventId> for rand::distributions::Standard {
5+
impl rand::distr::Distribution<ShortEventId> for rand::distr::StandardUniform {
76
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> ShortEventId {
87
let mut bytes = [0u8; 16];
98
rng.fill_bytes(&mut bytes);
@@ -12,7 +11,6 @@ impl rand::distributions::Distribution<ShortEventId> for rand::distributions::St
1211
}
1312
impl ShortEventId {
1413
pub fn random() -> Self {
15-
let mut csprng = OsRng;
16-
csprng.r#gen()
14+
rand::rng().random()
1715
}
1816
}

crates/rostra-web-ui/src/routes/post.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub async fn get_single_post(
3838
Path((author, event_id)): Path<(RostraId, ShortEventId)>,
3939
) -> RequestResult<impl IntoResponse> {
4040
// Render raw post if it's an HTMX request or raw=true query parameter
41-
if hx_request.is_htmx_request() || dbg!(query.raw) {
41+
if hx_request.is_htmx_request() || query.raw {
4242
let client_handle = state.client(session.id()).await?;
4343
let client_ref = client_handle.client_ref()?;
4444
let db = client_ref.db();
@@ -199,7 +199,7 @@ impl UiState {
199199
timestamp: Option<Timestamp>,
200200
ro: RoMode,
201201
) -> RequestResult<Markup> {
202-
// Note: we are actually not doing pagiantion, and just ignore
202+
// Note: we are actually not doing pagination, and just ignore
203203
// everything after first page
204204
let (reactions, _) = if let Some(event_id) = event_id {
205205
client
@@ -299,7 +299,7 @@ impl UiState {
299299
let external_event_id = event_id.map(|e| ExternalEventId::new(author, e));
300300
let user_profile = self.get_social_profile_opt(author, client).await;
301301

302-
// Note: we are actually not doing pagiantion, and just ignore
302+
// Note: we are actually not doing pagination, and just ignore
303303
// everything after first page
304304
let (reactions, _) = if let Some(event_id) = event_id {
305305
client

0 commit comments

Comments
 (0)