Skip to content

Commit

Permalink
Start the sync worker in the builder
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Dec 3, 2024
1 parent f6f9af9 commit 2ce4093
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
16 changes: 0 additions & 16 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,6 @@ impl FfiXmtpClient {
.register_identity(signature_request.clone())
.await?;

self.maybe_start_sync_worker().await?;

Ok(())
}

/// Starts the sync worker if the history sync url is present.
async fn maybe_start_sync_worker(&self) -> Result<(), GenericError> {
if self.inner_client.history_sync_url().is_none() {
return Ok(());
}

self.inner_client
.start_sync_worker()
.await
.map_err(GenericError::from_error)?;

Ok(())
}

Expand Down
8 changes: 6 additions & 2 deletions xmtp_mls/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,17 @@ where
)
.await?;

Ok(Client::new(
let client = Client::new(
api_client_wrapper,
identity,
store,
scw_verifier,
history_sync_url.clone(),
))
);

client.start_sync_worker().await?;

Ok(client)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/device_sync/consent_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ pub(crate) mod tests {
// 1.) UpdateGroupMembership Intent for new sync group
// 2.) Device Sync Request
// 3.) MessageHistory Sync Request
wait_for_min_intents(amal_b_conn, 3).await;
tracing::info!("Waiting for intents published");
wait_for_min_intents(amal_b_conn, 3).await;

let old_group_id = amal_a.get_sync_group(amal_a_conn).unwrap().group_id;
tracing::info!("Old Group Id: {}", hex::encode(&old_group_id));
Expand Down
6 changes: 1 addition & 5 deletions xmtp_mls/src/utils/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ where

register_client(&client, owner).await;

if client.history_sync_url.is_some() {
client.start_sync_worker().await.unwrap();
}

client
}

Expand Down Expand Up @@ -342,7 +338,7 @@ pub async fn wait_for_min_intents(conn: &DbConnection, n: usize) {

tracing::info!("{} intents left", intents.len());
if intents.len() < n {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
Box::pin(wait_for_min_intents(conn, n - intents.len())).await
}
}

0 comments on commit 2ce4093

Please sign in to comment.