Dastan-glitch 4 лет назад
Родитель
Сommit
3932a971ec
2 измененных файлов с 14 добавлено и 15 удалено
  1. 11 11
      src/bin/darkfid.rs
  2. 3 4
      src/bin/drk.rs

+ 11 - 11
src/bin/darkfid.rs

@@ -270,12 +270,12 @@ impl Darkfid {
     // <-- {"result": { "network": ["btc", "sol"] } }
     async fn features(&self, id: Value, _params: Value) -> JsonResult {
         let req = jsonreq(json!("features"), json!([]));
-        let rep: JsonResult;
+        let rep: JsonResult =
         // NOTE: this just selects the first cashier in the list
         match send_raw_request(&self.cashiers[0].rpc_url, json!(req)).await {
-            Ok(v) => rep = v,
+            Ok(v) => v,
             Err(e) => return JsonResult::Err(jsonerr(ServerError(-32004), Some(e.to_string()), id)),
-        }
+        };
 
         match rep {
             JsonResult::Resp(r) => JsonResult::Resp(r),
@@ -335,14 +335,13 @@ impl Darkfid {
         // (and token), it shall return a valid address where tokens can be deposited.
         // If not, an error is returned, and forwarded to the method caller.
         let req = jsonreq(json!("deposit"), json!([network, token_id, pubkey]));
-        let rep: JsonResult;
-        match send_raw_request(&self.cashiers[0].rpc_url, json!(req)).await {
-            Ok(v) => rep = v,
+        let rep: JsonResult = match send_raw_request(&self.cashiers[0].rpc_url, json!(req)).await {
+            Ok(v) => v,
             Err(e) => {
                 debug!(target: "DARKFID", "REQUEST IS ERR");
                 return JsonResult::Err(jsonerr(ServerError(-32004), Some(e.to_string()), id))
             }
-        }
+        };
 
         match rep {
             JsonResult::Resp(r) => JsonResult::Resp(r),
@@ -409,11 +408,12 @@ impl Darkfid {
         };
 
         let req = jsonreq(json!("withdraw"), json!([network, token_id, address, amount_in_apo]));
-        let mut rep: JsonResult;
-        match send_raw_request(&self.cashiers[0].rpc_url, json!(req)).await {
-            Ok(v) => rep = v,
+        let mut rep: JsonResult = match send_raw_request(&self.cashiers[0].rpc_url, json!(req))
+            .await
+        {
+            Ok(v) => v,
             Err(e) => return JsonResult::Err(jsonerr(ServerError(-32004), Some(e.to_string()), id)),
-        }
+        };
 
         let token_id: &DrkTokenId;
 

+ 3 - 4
src/bin/drk.rs

@@ -48,11 +48,10 @@ impl Drk {
     }
 
     async fn request(&self, r: jsonrpc::JsonRequest) -> Result<Value> {
-        let reply: JsonResult;
-        match jsonrpc::send_raw_request(&self.url, json!(r)).await {
-            Ok(v) => reply = v,
+        let reply: JsonResult = match jsonrpc::send_raw_request(&self.url, json!(r)).await {
+            Ok(v) => v,
             Err(e) => return Err(e),
-        }
+        };
 
         match reply {
             JsonResult::Resp(r) => {