Răsfoiți Sursa

todo.md: added error handling. cashierd2: removed old comments

lunar-mining 4 ani în urmă
părinte
comite
a25d2b8e06
2 a modificat fișierele cu 4 adăugiri și 4 ștergeri
  1. 3 4
      src/bin/cashierd.rs
  2. 1 0
      todo.md

+ 3 - 4
src/bin/cashierd.rs

@@ -99,8 +99,6 @@ impl Cashierd {
     }
 
     async fn start(&self, executor: Arc<Executor<'_>>) -> Result<()> {
-        //// TODO: pass vector of assets
-
         self.cashier_wallet.init_db()?;
 
         let bridge = Bridge::new();
@@ -193,7 +191,6 @@ impl Cashierd {
 
         debug!(target: "RPC", "--> {:#?}", serde_json::to_string(&req).unwrap());
 
-        // TODO: "features"
         match req.method.as_str() {
             Some("deposit") => return self.deposit(req.id, req.params).await,
             Some("withdraw") => return self.withdraw(req.id, req.params).await,
@@ -220,6 +217,7 @@ impl Cashierd {
 
         debug!(target: "CASHIER", "PROCESSING INPUT");
 
+        // TODO: proper error handling
         let token_id = self.clone().parse_id(tkn);
 
         if pk.as_str().is_none() {
@@ -244,6 +242,8 @@ impl Cashierd {
         JsonResult::Resp(jsonresp(json!(pubkey), json!(id)))
     }
 
+    // here we hash the alphanumeric token ID. if it fails, we change the last 4 bytes and hash it
+    // again, and keep repeating until it works.
     async fn parse_id(self, token: &Value) -> Result<jubjub::Fr> {
         let tkn_str = token.as_str().unwrap();
         if bs58::decode(tkn_str).into_vec().is_err() {
@@ -290,7 +290,6 @@ impl Cashierd {
         JsonResult::Err(jsonerr(InvalidParams, None, id))
     }
 
-    // TODO: implement this
     async fn features(self, id: Value, _params: Value) -> JsonResult {
         JsonResult::Resp(jsonresp(json!(self.features), id))
     }

+ 1 - 0
todo.md

@@ -15,6 +15,7 @@
 - [ ] delete deprecated rpc code 
 - [ ] drk2: check user input is valid tokenID and not symbol
 - [ ] drk2: retrieve cashier features and error if don't support the network
+- [ ] standardize error handling in drk2, cashierd, darkfid
 
 ## deposit