Skip to content

Commit f5bfd52

Browse files
author
Mauve Signweaver
committed
fix: Use ureliable low latency routes with latest v-i-b version
1 parent 0cc46fc commit f5bfd52

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ serial_test = "3.1.1"
2626
url = "2.5.2"
2727
hex = "0.4.3"
2828
rand = "0.8.5"
29-
base64 = "0.22.1"
29+
base64 = "0.22.1"

src/backend.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ impl Backend {
160160
});
161161

162162
let (route_id, route_id_blob) = make_route(&veilid_api).await?;
163-
let routing_context = veilid_api
164-
.routing_context()?
165-
.with_sequencing(veilid_core::Sequencing::EnsureOrdered);
163+
let routing_context = veilid_api.routing_context()?;
166164

167165
let mut inner = backend.inner.lock().await;
168166

@@ -206,9 +204,7 @@ impl Backend {
206204
let (route_id, route_id_blob) = make_route(&veilid_api).await?;
207205

208206
// Get veilid_api and routing_context
209-
let routing_context = veilid_api
210-
.routing_context()?
211-
.with_sequencing(veilid_core::Sequencing::EnsureOrdered);
207+
let routing_context = veilid_api.routing_context()?;
212208

213209
let inner_clone = self.inner.clone();
214210

src/group.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use tokio::sync::{mpsc, Mutex};
2121
use url::Url;
2222
use veilid_core::{
2323
CryptoKey, CryptoSystemVLD0, CryptoTyped, DHTRecordDescriptor, DHTReportScope, DHTSchema,
24-
KeyPair, ProtectedStore, RoutingContext, SharedSecret, TypedKey, ValueSubkeyRangeSet, VeilidUpdate,
25-
VeilidAPI, CRYPTO_KEY_LENGTH, CRYPTO_KIND_VLD0,
24+
KeyPair, ProtectedStore, RoutingContext, SharedSecret, TypedKey, ValueSubkeyRangeSet,
25+
VeilidAPI, VeilidUpdate, CRYPTO_KEY_LENGTH, CRYPTO_KIND_VLD0,
2626
};
2727
use veilid_iroh_blobs::iroh::VeilidIrohBlobs;
2828

@@ -83,7 +83,8 @@ impl Group {
8383
.lock()
8484
.await
8585
.get(id)
86-
.ok_or_else(|| anyhow!("Repo not loaded")).cloned()
86+
.ok_or_else(|| anyhow!("Repo not loaded"))
87+
.cloned()
8788
}
8889

8990
pub async fn has_repo(&self, id: &CryptoKey) -> bool {
@@ -130,12 +131,6 @@ impl Group {
130131

131132
for repo in repos.iter() {
132133
if let Ok(route_id_blob) = repo.get_route_id_blob().await {
133-
println!(
134-
"Downloading {} from {} via {:?}",
135-
hash,
136-
repo.id(),
137-
route_id_blob
138-
);
139134
// It's faster to try and fail, than to ask then try
140135
let result = self
141136
.iroh_blobs
@@ -474,7 +469,7 @@ impl Group {
474469
.await
475470
.map_err(|_| anyhow!("Failed to load keypair for repo_id: {:?}", repo_id))
476471
}
477-
472+
478473
pub async fn watch_changes<F, Fut>(&self, on_change: F) -> Result<()>
479474
where
480475
F: Fn() -> Fut + Send + Sync + 'static,
@@ -486,11 +481,10 @@ impl Group {
486481
} else {
487482
ValueSubkeyRangeSet::full()
488483
};
489-
484+
490485
let expiration_duration = 600_000_000;
491-
let expiration = SystemTime::now()
492-
.duration_since(UNIX_EPOCH)?
493-
.as_micros() as u64 + expiration_duration;
486+
let expiration =
487+
SystemTime::now().duration_since(UNIX_EPOCH)?.as_micros() as u64 + expiration_duration;
494488
let count = 0;
495489

496490
// Clone necessary data for the async block
@@ -500,15 +494,28 @@ impl Group {
500494
// Spawn a task that uses only owned data
501495
tokio::spawn(async move {
502496
match routing_context
503-
.watch_dht_values(dht_record_key.clone(), range.clone(), expiration.into(), count)
497+
.watch_dht_values(
498+
dht_record_key.clone(),
499+
range.clone(),
500+
expiration.into(),
501+
count,
502+
)
504503
.await
505504
{
506505
Ok(_) => {
507-
println!("DHT watch successfully set on record key {:?}", dht_record_key);
506+
println!(
507+
"DHT watch successfully set on record key {:?}",
508+
dht_record_key
509+
);
508510

509511
loop {
510512
if let Ok(change) = routing_context
511-
.watch_dht_values(dht_record_key.clone(), range.clone(), expiration.into(), count)
513+
.watch_dht_values(
514+
dht_record_key.clone(),
515+
range.clone(),
516+
expiration.into(),
517+
count,
518+
)
512519
.await
513520
{
514521
if change > 0.into() {
@@ -525,8 +532,6 @@ impl Group {
525532

526533
Ok(())
527534
}
528-
529-
530535
}
531536

532537
impl DHTEntity for Group {

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,11 @@ mod tests {
832832
.await
833833
.expect("Unable to create group");
834834

835+
group.set_name("Example").await?;
836+
835837
let mut peer_repo = group.create_repo().await?;
836838

837-
sleep(Duration::from_secs(1)).await;
839+
sleep(Duration::from_secs(2)).await;
838840

839841
let group2 = backend2.join_from_url(&group.get_url()).await?;
840842

@@ -871,7 +873,7 @@ mod tests {
871873
"New collection hash after uploading a file should not be empty"
872874
);
873875

874-
sleep(Duration::from_secs(8)).await;
876+
sleep(Duration::from_secs(2)).await;
875877

876878
// Download hash from peers
877879
let mut retries = 5;
@@ -882,7 +884,10 @@ mod tests {
882884
retries -= 1;
883885
sleep(Duration::from_secs(4)).await;
884886
}
885-
assert!(retries > 0, "Failed to download hash from peers after retries");
887+
assert!(
888+
retries > 0,
889+
"Failed to download hash from peers after retries"
890+
);
886891

887892
backend1.stop().await?;
888893
backend2.stop().await?;

0 commit comments

Comments
 (0)