Просмотр исходного кода

renamed parse_id to generate_id

lunar-mining 4 лет назад
Родитель
Сommit
97083e4592
3 измененных файлов с 8 добавлено и 7 удалено
  1. 3 3
      src/bin/cashierd.rs
  2. 4 3
      src/bin/darkfid.rs
  3. 1 1
      src/util.rs

+ 3 - 3
src/bin/cashierd.rs

@@ -20,7 +20,7 @@ use drk::{
     },
     serial::{deserialize, serialize},
     service::{bridge, bridge::Bridge},
-    util::{expand_path, join_config_path},
+    util::{expand_path, generate_id, join_config_path},
     wallet::{CashierDb, WalletDb},
     Error, Result,
 };
@@ -298,7 +298,7 @@ impl Cashierd {
         let result: Result<String> = async {
             Self::check_token_id(&network, token_id.as_str().unwrap())?;
 
-            let asset_id = drk::util::parse_id(token_id)?;
+            let asset_id = generate_id(token_id)?;
 
             let drk_pub_key = bs58::decode(&drk_pub_key).into_vec()?;
             let drk_pub_key: jubjub::SubgroupPoint = deserialize(&drk_pub_key)?;
@@ -393,7 +393,7 @@ impl Cashierd {
         let result: Result<String> = async {
             Self::check_token_id(&network, token.as_str().unwrap())?;
 
-            let asset_id = drk::util::parse_id(&token)?;
+            let asset_id = generate_id(&token)?;
             let address = serialize(&address.to_string());
 
             let cashier_public: jubjub::SubgroupPoint;

+ 4 - 3
src/bin/darkfid.rs

@@ -16,7 +16,7 @@ use drk::{
         rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig},
     },
     serial::{deserialize, serialize},
-    util::{expand_path, join_config_path, parse_id},
+    util::{expand_path, generate_id, join_config_path},
     wallet::WalletDb,
     Error, Result,
 };
@@ -349,13 +349,13 @@ impl Darkfid {
         match token.as_str() {
             Some("sol") | Some("SOL") => {
                 let id = "So11111111111111111111111111111111111111112";
-                let token_id = parse_id(&json!(id))?;
+                let token_id = generate_id(&json!(id))?;
                 Ok(token_id)
             }
             Some("btc") | Some("BTC") => Err(Error::TokenParseError),
             Some(tkn) => {
                 let id = self.parse_token(tkn)?;
-                let token_id = parse_id(&id)?;
+                let token_id = generate_id(&id)?;
                 Ok(token_id)
             }
             None => Err(Error::TokenParseError),
@@ -380,6 +380,7 @@ impl Darkfid {
         }
     }
 
+    // symbol to id
     fn parse_token(&self, token: &str) -> Result<Value> {
         let vec: Vec<char> = token.chars().collect();
         let mut counter = 0;

+ 1 - 1
src/util.rs

@@ -40,7 +40,7 @@ pub fn join_config_path(file: &Path) -> Result<PathBuf> {
 
 // 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.
-pub fn parse_id(token: &Value) -> Result<jubjub::Fr> {
+pub fn generate_id(token: &Value) -> Result<jubjub::Fr> {
     let tkn_str = token.as_str().unwrap();
     if bs58::decode(tkn_str).into_vec().is_err() {
         // TODO: make this an error