From 7166252ccc78aafe48c857a659ace045adc1a555 Mon Sep 17 00:00:00 2001 From: "Ryan.K" Date: Sun, 17 Mar 2024 01:57:43 +0000 Subject: [PATCH] fmt --- crates/core/src/swarm/mod.rs | 2 +- crates/node/src/backend/snark/browser.rs | 6 +++++- crates/node/src/backend/snark/mod.rs | 7 ++++++- crates/node/src/provider/browser/provider.rs | 11 +++++------ crates/node/src/tests/wasm/snark.rs | 7 +++++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/crates/core/src/swarm/mod.rs b/crates/core/src/swarm/mod.rs index 02e95ec2..b0917f45 100644 --- a/crates/core/src/swarm/mod.rs +++ b/crates/core/src/swarm/mod.rs @@ -350,7 +350,7 @@ impl PayloadSender for Swarm { let result = if data.len() > TRANSPORT_MTU { let chunks = ChunkList::::from(&data); - tracing::info!("data splited to chunk, len {}", chunks.to_vec().len()); + tracing::info!("data split to chunk, len {}", chunks.to_vec().len()); for chunk in chunks { let data = MessagePayload::new_send(Message::Chunk(chunk), &self.session_sk, did, did)? diff --git a/crates/node/src/backend/snark/browser.rs b/crates/node/src/backend/snark/browser.rs index 0654a688..07124d03 100644 --- a/crates/node/src/backend/snark/browser.rs +++ b/crates/node/src/backend/snark/browser.rs @@ -176,7 +176,11 @@ impl SNARKBehaviour { let ins = self.clone(); future_to_promise(async move { let ret = ins - .send_proof_task(provider.inner().clone(), task.as_ref(), Did::from_str(&did)?) + .send_proof_task( + provider.inner().clone(), + task.as_ref(), + Did::from_str(&did)?, + ) .await .map_err(JsError::from)?; Ok(JsValue::from(ret)) diff --git a/crates/node/src/backend/snark/mod.rs b/crates/node/src/backend/snark/mod.rs index eef6405b..b84bd4a2 100644 --- a/crates/node/src/backend/snark/mod.rs +++ b/crates/node/src/backend/snark/mod.rs @@ -939,7 +939,12 @@ impl MessageHandler for SNARKBehaviour { } .into(); let params = resp.into_send_backend_message_request(verifier)?; - provider.request_internal(Method::SendBackendMessage.to_string(), serde_json::to_value(params)?).await?; + provider + .request_internal( + Method::SendBackendMessage.to_string(), + serde_json::to_value(params)?, + ) + .await?; Ok(()) } SNARKTask::SNARKVerify(t) => { diff --git a/crates/node/src/provider/browser/provider.rs b/crates/node/src/provider/browser/provider.rs index a353eca6..c2336bdc 100644 --- a/crates/node/src/provider/browser/provider.rs +++ b/crates/node/src/provider/browser/provider.rs @@ -70,18 +70,17 @@ impl TryFrom<&Peer> for JsValue { } } - /// A wrapper of Arc Ref of Provider #[derive(Clone)] #[wasm_export] pub struct ProviderRef { - inner: Arc + inner: Arc, } impl ProviderRef { /// get wrapped arc, this is useful for wasm case pub fn inner(&self) -> Arc { - self.inner.clone() + self.inner.clone() } } @@ -89,9 +88,9 @@ impl ProviderRef { impl Provider { /// make provider as an As arc ref pub fn as_ref(&self) -> ProviderRef { - ProviderRef { - inner: Arc::new(self.clone()) - } + ProviderRef { + inner: Arc::new(self.clone()), + } } } diff --git a/crates/node/src/tests/wasm/snark.rs b/crates/node/src/tests/wasm/snark.rs index f13a7084..22ddd201 100644 --- a/crates/node/src/tests/wasm/snark.rs +++ b/crates/node/src/tests/wasm/snark.rs @@ -65,7 +65,10 @@ async fn test_send_snark_backend_message() { console_log!("wait for register"); js_utils::window_sleep(1000).await.unwrap(); console_log!("gen snark task and send"); - let promise = - snark_behaviour.gen_and_send_proof_task_to(provider1.as_ref(), circuits, provider2.address()); + let promise = snark_behaviour.gen_and_send_proof_task_to( + provider1.as_ref(), + circuits, + provider2.address(), + ); wasm_bindgen_futures::JsFuture::from(promise).await.unwrap(); }