Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 094b4ed

Browse files
author
Mauve Signweaver
committedOct 31, 2024·
Ensure ordered routing context
1 parent a843560 commit 094b4ed

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed
 

‎src/backend.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ impl Backend {
128128

129129
let on_new_route_callback: OnNewRouteCallback = Arc::new(move |_, _| {
130130
let inner = inner_clone.clone();
131+
println!("Re-generating route");
131132
tokio::spawn(async move {
132133
let inner = inner.lock().await;
133134

@@ -151,7 +152,9 @@ impl Backend {
151152
});
152153

153154
let (route_id, route_id_blob) = make_route(&veilid_api).await?;
154-
let routing_context = veilid_api.routing_context()?;
155+
let routing_context = veilid_api
156+
.routing_context()?
157+
.with_sequencing(veilid_core::Sequencing::EnsureOrdered);
155158

156159
let mut inner = backend.inner.lock().await;
157160

@@ -195,12 +198,15 @@ impl Backend {
195198
let (route_id, route_id_blob) = make_route(&veilid_api).await?;
196199

197200
// Get veilid_api and routing_context
198-
let routing_context = veilid_api.routing_context()?;
201+
let routing_context = veilid_api
202+
.routing_context()?
203+
.with_sequencing(veilid_core::Sequencing::EnsureOrdered);
199204

200205
let inner_clone = self.inner.clone();
201206

202207
let on_new_route_callback: OnNewRouteCallback = Arc::new(move |_, _| {
203208
let inner = inner_clone.clone();
209+
println!("Re-generating route");
204210
tokio::spawn(async move {
205211
let inner = inner.lock().await;
206212

‎src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub async fn make_route(veilid: &VeilidAPI) -> Result<(RouteId, Vec<u8>)> {
2020
.new_custom_private_route(
2121
&VALID_CRYPTO_KINDS,
2222
Stability::Reliable,
23-
Sequencing::PreferOrdered,
23+
Sequencing::EnsureOrdered,
2424
)
2525
.await;
2626

‎src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ mod tests {
831831

832832
let mut peer_repo = group.create_repo().await?;
833833

834+
sleep(Duration::from_secs(1)).await;
835+
834836
let group2 = backend2.join_from_url(&group.get_url()).await?;
835837

836838
// Upload a test blob to the peer repo
@@ -963,6 +965,8 @@ mod tests {
963965
"New collection hash after uploading a file should not be empty"
964966
);
965967

968+
sleep(Duration::from_secs(4)).await;
969+
966970
let joined_group = backend2
967971
.join_from_url(&group1.get_url())
968972
.await

‎src/repo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ impl Repo {
225225
// Method to retrieve a file's hash from the collection
226226
pub async fn get_file_hash(&self, file_name: &str) -> Result<Hash> {
227227
// Ensure the collection exists before reading
228-
self.get_or_create_collection().await?;
228+
let collection_hash = self.get_or_create_collection().await?;
229229

230-
let collection_hash = self.get_collection_hash().await?;
231230
self.iroh_blobs
232231
.get_file_from_collection_hash(&collection_hash, file_name)
233232
.await

0 commit comments

Comments
 (0)
Please sign in to comment.