Browse Source

Code linting.

parazyd 4 years ago
parent
commit
19727d1528

+ 4 - 6
src/bin/darkfid.rs

@@ -56,8 +56,7 @@ impl RequestHandler for Darkfid {
 impl Darkfid {
 impl Darkfid {
     fn new(config_path: PathBuf) -> Result<Self> {
     fn new(config_path: PathBuf) -> Result<Self> {
         let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
         let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
-        let wallet_path = join_config_path(&PathBuf::from("walletdb.db"))?;
-        let wallet = WalletDb::new(&PathBuf::from(wallet_path.clone()), config.password.clone())?;
+        let wallet = WalletDb::new(&PathBuf::from(&config.wallet_path), config.password.clone())?;
         let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
         let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
         let tokenlist: Value = serde_json::from_str(&file_contents)?;
         let tokenlist: Value = serde_json::from_str(&file_contents)?;
 
 
@@ -179,7 +178,7 @@ impl Darkfid {
             return JsonResult::Err(jsonerr(InvalidParams, None, id));
             return JsonResult::Err(jsonerr(InvalidParams, None, id));
         }
         }
 
 
-        let tkn_str = token.as_str().unwrap();
+        let _tkn_str = token.as_str().unwrap();
 
 
         // check if the token input is an ID
         // check if the token input is an ID
         // if not, find the associated ID
         // if not, find the associated ID
@@ -228,11 +227,10 @@ impl Darkfid {
             }
             }
         }
         }
         if counter == token.len() {
         if counter == token.len() {
-            let token_id = self.search_id(token);
-            return token_id;
+            self.search_id(token)
         } else {
         } else {
             let token_id: Value = serde_json::from_str(token).unwrap();
             let token_id: Value = serde_json::from_str(token).unwrap();
-            return token_id;
+            token_id
         }
         }
     }
     }
 
 

+ 4 - 4
src/blockchain/rocks.rs

@@ -1,6 +1,6 @@
 use async_std::sync::Arc;
 use async_std::sync::Arc;
 use std::marker::PhantomData;
 use std::marker::PhantomData;
-use std::path::PathBuf;
+use std::path::Path;
 
 
 use crate::serial::{deserialize, serialize, Decodable, Encodable};
 use crate::serial::{deserialize, serialize, Decodable, Encodable};
 use crate::{Error, Result};
 use crate::{Error, Result};
@@ -39,7 +39,7 @@ pub struct Rocks {
 }
 }
 
 
 impl Rocks {
 impl Rocks {
-    pub fn new(path: &PathBuf) -> Result<Arc<Self>> {
+    pub fn new(path: &Path) -> Result<Arc<Self>> {
         // column family options
         // column family options
         let cf_opts = Options::default();
         let cf_opts = Options::default();
 
 
@@ -73,7 +73,7 @@ impl Rocks {
     {
     {
         self.db
         self.db
             .cf_handle(C::NAME)
             .cf_handle(C::NAME)
-            .ok_or(Error::RocksdbError("unknown column".to_string()))
+            .ok_or_else(|| Error::RocksdbError("unknown column".to_string()))
     }
     }
 
 
     pub fn put_cf(&self, cf: &ColumnFamily, key: Vec<u8>, value: Vec<u8>) -> Result<()> {
     pub fn put_cf(&self, cf: &ColumnFamily, key: Vec<u8>, value: Vec<u8>) -> Result<()> {
@@ -99,7 +99,7 @@ impl Rocks {
         self.db.iterator_cf(cf, iterator_mode)
         self.db.iterator_cf(cf, iterator_mode)
     }
     }
 
 
-    pub fn destroy(path: &PathBuf) -> Result<()> {
+    pub fn destroy(path: &Path) -> Result<()> {
         DB::destroy(&Options::default(), path)?;
         DB::destroy(&Options::default(), path)?;
         Ok(())
         Ok(())
     }
     }

+ 1 - 1
src/blockchain/slabstore.rs

@@ -25,7 +25,7 @@ impl SlabStore {
         let key = last_index + 1;
         let key = last_index + 1;
 
 
         if slab.get_index() == key {
         if slab.get_index() == key {
-            self.rocks.put(key.clone(), slab)?;
+            self.rocks.put(key, slab)?;
             Ok(Some(key))
             Ok(Some(key))
         } else {
         } else {
             Ok(None)
             Ok(None)

+ 2 - 2
src/circuit/spend_contract.rs

@@ -112,7 +112,7 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
         let mut nf_preimage = vec![];
         let mut nf_preimage = vec![];
 
 
         // Line 64: binary_clone secret2 secret
         // Line 64: binary_clone secret2 secret
-        let mut secret2: Vec<_> = secret.iter().cloned().collect();
+        let mut secret2: Vec<_> = secret.to_vec();
 
 
         // Line 65: binary_extend nf_preimage secret2
         // Line 65: binary_extend nf_preimage secret2
         nf_preimage.extend(secret2);
         nf_preimage.extend(secret2);
@@ -142,7 +142,7 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
         nf_preimage.push(zero_bit);
         nf_preimage.push(zero_bit);
 
 
         // Line 81: binary_clone serial2 serial
         // Line 81: binary_clone serial2 serial
-        let mut serial2: Vec<_> = serial.iter().cloned().collect();
+        let mut serial2: Vec<_> = serial.to_vec();
 
 
         // Line 82: binary_extend nf_preimage serial2
         // Line 82: binary_extend nf_preimage serial2
         nf_preimage.extend(serial2);
         nf_preimage.extend(serial2);

+ 4 - 3
src/cli/cli_config.rs

@@ -19,7 +19,7 @@ impl<T: Serialize + DeserializeOwned> Config<T> {
         if Path::new(&path).exists() {
         if Path::new(&path).exists() {
             let toml = fs::read(&path)?;
             let toml = fs::read(&path)?;
             let str_buff = str::from_utf8(&toml)?;
             let str_buff = str::from_utf8(&toml)?;
-            let config: T = toml::from_str(str_buff.clone())?;
+            let config: T = toml::from_str(str_buff)?;
             Ok(config)
             Ok(config)
         } else {
         } else {
             println!("No config files were found in .config/darkfi. Please follow the instructions in the README and add default configs.");
             println!("No config files were found in .config/darkfi. Please follow the instructions in the README and add default configs.");
@@ -60,8 +60,9 @@ pub struct DarkfidConfig {
     //TODO: reimplement this
     //TODO: reimplement this
     //#[serde(rename = "database_path")]
     //#[serde(rename = "database_path")]
     //pub database_path: String,
     //pub database_path: String,
-    //#[serde(rename = "walletdb_path")]
-    //pub walletdb_path: String,
+    #[serde(rename = "wallet_path")]
+    pub wallet_path: String,
+
     #[serde(rename = "log_path")]
     #[serde(rename = "log_path")]
     pub log_path: String,
     pub log_path: String,
 
 

+ 19 - 31
src/client/client.rs

@@ -86,10 +86,7 @@ impl Client {
         Ok(())
         Ok(())
     }
     }
 
 
-    pub async fn connect_to_cashier(
-        client: Client,
-        executor: Arc<Executor<'_>>,
-    ) -> Result<()> {
+    pub async fn connect_to_cashier(client: Client, executor: Arc<Executor<'_>>) -> Result<()> {
         let client_mutex = Arc::new(Mutex::new(client));
         let client_mutex = Arc::new(Mutex::new(client));
 
 
         // start subscriber
         // start subscriber
@@ -99,34 +96,29 @@ impl Client {
     }
     }
 
 
     pub async fn transfer(
     pub async fn transfer(
-        self: &mut Self,
+        &mut self,
         asset_id: jubjub::Fr,
         asset_id: jubjub::Fr,
         pub_key: jubjub::SubgroupPoint,
         pub_key: jubjub::SubgroupPoint,
+        // TODO: FIX THIS
         amount: f64,
         amount: f64,
     ) -> Result<()> {
     ) -> Result<()> {
         if amount <= 0.0 {
         if amount <= 0.0 {
             return Err(ClientFailed::InvalidAmount(amount as u64).into());
             return Err(ClientFailed::InvalidAmount(amount as u64).into());
         }
         }
 
 
-        self.send(pub_key.clone(), amount.clone() as u64, asset_id, false)
-            .await?;
+        self.send(pub_key, amount as u64, asset_id, false).await?;
 
 
         Ok(())
         Ok(())
     }
     }
 
 
     pub async fn send(
     pub async fn send(
-        self: &mut Self,
+        &mut self,
         pub_key: jubjub::SubgroupPoint,
         pub_key: jubjub::SubgroupPoint,
         amount: u64,
         amount: u64,
         asset_id: jubjub::Fr,
         asset_id: jubjub::Fr,
         clear_input: bool,
         clear_input: bool,
     ) -> Result<()> {
     ) -> Result<()> {
-        let slab = self.build_slab_from_tx(
-            pub_key.clone(),
-            amount.clone() as u64,
-            asset_id,
-            clear_input,
-        )?;
+        let slab = self.build_slab_from_tx(pub_key, amount, asset_id, clear_input)?;
 
 
         self.gateway.put_slab(slab).await?;
         self.gateway.put_slab(slab).await?;
 
 
@@ -136,7 +128,7 @@ impl Client {
     fn build_slab_from_tx(
     fn build_slab_from_tx(
         &self,
         &self,
         pub_key: jubjub::SubgroupPoint,
         pub_key: jubjub::SubgroupPoint,
-        amount: u64,
+        value: u64,
         asset_id: jubjub::Fr,
         asset_id: jubjub::Fr,
         clear_input: bool,
         clear_input: bool,
     ) -> Result<Slab> {
     ) -> Result<Slab> {
@@ -145,19 +137,19 @@ impl Client {
         let mut outputs: Vec<tx::TransactionBuilderOutputInfo> = vec![];
         let mut outputs: Vec<tx::TransactionBuilderOutputInfo> = vec![];
 
 
         if clear_input {
         if clear_input {
-            let cashier_secret = self.state.wallet.get_keypairs()?[0].private;
+            let signature_secret = self.state.wallet.get_keypairs()?[0].private;
             let input = tx::TransactionBuilderClearInputInfo {
             let input = tx::TransactionBuilderClearInputInfo {
-                value: amount,
+                value,
                 asset_id,
                 asset_id,
-                signature_secret: cashier_secret.clone(),
+                signature_secret,
             };
             };
             clear_inputs.push(input);
             clear_inputs.push(input);
         } else {
         } else {
-            inputs = self.build_inputs(amount.clone(), asset_id, &mut outputs)?;
+            inputs = self.build_inputs(value, asset_id, &mut outputs)?;
         }
         }
 
 
         outputs.push(tx::TransactionBuilderOutputInfo {
         outputs.push(tx::TransactionBuilderOutputInfo {
-            value: amount,
+            value,
             asset_id,
             asset_id,
             public: pub_key,
             public: pub_key,
         });
         });
@@ -375,12 +367,11 @@ impl State {
             // Also update all the coin witnesses
             // Also update all the coin witnesses
             for (coin_id, witness) in self.wallet.get_witnesses()?.iter_mut() {
             for (coin_id, witness) in self.wallet.get_witnesses()?.iter_mut() {
                 witness.append(node).expect("Append to witness");
                 witness.append(node).expect("Append to witness");
-                self.wallet
-                    .update_witness(coin_id.clone(), witness.clone())?;
+                self.wallet.update_witness(*coin_id, witness.clone())?;
             }
             }
 
 
             for secret in secret_keys.iter() {
             for secret in secret_keys.iter() {
-                if let Some(note) = Self::try_decrypt_note(enc_note.clone(), secret.clone()) {
+                if let Some(note) = Self::try_decrypt_note(enc_note, *secret) {
                     // We need to keep track of the witness for this coin.
                     // We need to keep track of the witness for this coin.
                     // This allows us to prove inclusion of the coin in the merkle tree with ZK.
                     // This allows us to prove inclusion of the coin in the merkle tree with ZK.
                     // Just as we update the merkle tree with every new coin, so we do the same with
                     // Just as we update the merkle tree with every new coin, so we do the same with
@@ -396,7 +387,7 @@ impl State {
                     let own_coin = OwnCoin {
                     let own_coin = OwnCoin {
                         coin: coin.clone(),
                         coin: coin.clone(),
                         note: note.clone(),
                         note: note.clone(),
-                        secret: secret.clone(),
+                        secret: *secret,
                         witness: witness.clone(),
                         witness: witness.clone(),
                     };
                     };
 
 
@@ -411,13 +402,10 @@ impl State {
 
 
     fn try_decrypt_note(ciphertext: &EncryptedNote, secret: jubjub::Fr) -> Option<Note> {
     fn try_decrypt_note(ciphertext: &EncryptedNote, secret: jubjub::Fr) -> Option<Note> {
         match ciphertext.decrypt(&secret) {
         match ciphertext.decrypt(&secret) {
-            Ok(note) => {
-                // ... and return the decrypted note for this coin.
-                return Some(note);
-            }
-            Err(_) => {}
+            // ... and return the decrypted note for this coin.
+            Ok(note) => Some(note),
+            // We weren't able to decrypt the note with our key.
+            Err(_) => None,
         }
         }
-        // We weren't able to decrypt the note with our key.
-        None
     }
     }
 }
 }

+ 1 - 1
src/crypto/coin.rs

@@ -18,7 +18,7 @@ impl Coin {
 
 
 impl Encodable for Coin {
 impl Encodable for Coin {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
-        Ok(self.repr.encode(s)?)
+        self.repr.encode(s)
     }
     }
 }
 }
 
 

+ 1 - 1
src/crypto/merkle_node.rs

@@ -120,7 +120,7 @@ impl From<MerkleNode> for bls12_381::Scalar {
 
 
 impl Encodable for MerkleNode {
 impl Encodable for MerkleNode {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
-        Ok(self.repr.encode(s)?)
+        self.repr.encode(s)
     }
     }
 }
 }
 
 

+ 2 - 1
src/crypto/mint_proof.rs

@@ -33,7 +33,7 @@ impl MintRevealedValues {
                 * randomness_value);
                 * randomness_value);
 
 
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
-            * jubjub::Fr::from(asset_id))
+            * asset_id)
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
                 * randomness_asset);
                 * randomness_asset);
 
 
@@ -136,6 +136,7 @@ pub fn setup_mint_prover() -> groth16::Parameters<Bls12> {
     params
     params
 }
 }
 
 
+#[allow(clippy::too_many_arguments)]
 pub fn create_mint_proof(
 pub fn create_mint_proof(
     params: &groth16::Parameters<Bls12>,
     params: &groth16::Parameters<Bls12>,
     value: u64,
     value: u64,

+ 1 - 1
src/crypto/nullifier.rs

@@ -17,7 +17,7 @@ impl Nullifier {
 
 
 impl Encodable for Nullifier {
 impl Encodable for Nullifier {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
     fn encode<S: io::Write>(&self, s: S) -> Result<usize> {
-        Ok(self.repr.encode(s)?)
+        self.repr.encode(s)
     }
     }
 }
 }
 
 

+ 5 - 3
src/crypto/spend_proof.rs

@@ -25,6 +25,7 @@ pub struct SpendRevealedValues {
 }
 }
 
 
 impl SpendRevealedValues {
 impl SpendRevealedValues {
+    #[allow(clippy::too_many_arguments)]
     fn compute(
     fn compute(
         value: u64,
         value: u64,
         asset_id: jubjub::Fr,
         asset_id: jubjub::Fr,
@@ -42,7 +43,7 @@ impl SpendRevealedValues {
                 * randomness_value);
                 * randomness_value);
 
 
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
         let asset_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR
-            * jubjub::Fr::from(asset_id))
+            * asset_id)
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
             + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR
                 * randomness_asset);
                 * randomness_asset);
 
 
@@ -221,6 +222,7 @@ pub fn setup_spend_prover() -> groth16::Parameters<Bls12> {
     params
     params
 }
 }
 
 
+#[allow(clippy::too_many_arguments)]
 pub fn create_spend_proof(
 pub fn create_spend_proof(
     params: &groth16::Parameters<Bls12>,
     params: &groth16::Parameters<Bls12>,
     value: u64,
     value: u64,
@@ -237,8 +239,8 @@ pub fn create_spend_proof(
     let mut branch: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     let mut branch: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     let mut is_right: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     let mut is_right: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     for (i, (branch_i, is_right_i)) in merkle_path.iter().enumerate() {
     for (i, (branch_i, is_right_i)) in merkle_path.iter().enumerate() {
-        branch[i] = Some(branch_i.clone());
-        is_right[i] = Some(is_right_i.clone());
+        branch[i] = Some(*branch_i);
+        is_right[i] = Some(*is_right_i);
     }
     }
     let c = SpendContract {
     let c = SpendContract {
         value: Some(value),
         value: Some(value),

+ 2 - 1
src/lib.rs

@@ -92,6 +92,7 @@ impl ZkContract {
         }
         }
 
 
         // execute
         // execute
+        //let params = std::mem::take(&mut self.params);
         let params = std::mem::replace(&mut self.params, HashMap::default());
         let params = std::mem::replace(&mut self.params, HashMap::default());
         self.vm.initialize(&params.into_iter().collect())?;
         self.vm.initialize(&params.into_iter().collect())?;
 
 
@@ -116,7 +117,7 @@ impl ZkContract {
         for (name, value) in &proof.public {
         for (name, value) in &proof.public {
             match self.public_map.get_by_left(name) {
             match self.public_map.get_by_left(name) {
                 Some(index) => {
                 Some(index) => {
-                    public.push((index, value.clone()));
+                    public.push((index, *value));
                 }
                 }
                 None => return false,
                 None => return false,
             }
             }

+ 1 - 1
src/net/channel.rs

@@ -168,7 +168,7 @@ impl Channel {
     /// End of file error. Triggered when unexpected end of file occurs.
     /// End of file error. Triggered when unexpected end of file occurs.
     fn is_eof_error(err: Error) -> bool {
     fn is_eof_error(err: Error) -> bool {
         match err {
         match err {
-            Error::Io(io_err) => io_err.clone() == std::io::ErrorKind::UnexpectedEof,
+            Error::Io(io_err) => io_err == std::io::ErrorKind::UnexpectedEof,
             _ => false,
             _ => false,
         }
         }
     }
     }

+ 1 - 1
src/net/hosts.rs

@@ -21,7 +21,7 @@ impl Hosts {
     }
     }
 
 
     /// Checks if a host address is in the host list.
     /// Checks if a host address is in the host list.
-    async fn contains(&self, addrs: &Vec<SocketAddr>) -> bool {
+    async fn contains(&self, addrs: &[SocketAddr]) -> bool {
         let a_set: HashSet<_> = addrs.iter().copied().collect();
         let a_set: HashSet<_> = addrs.iter().copied().collect();
         self.addrs
         self.addrs
             .lock()
             .lock()

+ 6 - 0
src/net/message_subscriber.rs

@@ -236,6 +236,12 @@ impl MessageSubsystem {
     }
     }
 }
 }
 
 
+impl Default for MessageSubsystem {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 /// Test functions for message subsystem.
 /// Test functions for message subsystem.
 // This is a test function for the message subsystem code above
 // This is a test function for the message subsystem code above
 // Normall we would use the #[test] macro but cannot since it is async code
 // Normall we would use the #[test] macro but cannot since it is async code

+ 1 - 1
src/net/messages.rs

@@ -220,7 +220,7 @@ pub async fn send_packet<W: AsyncWrite + Unpin>(stream: &mut W, packet: Packet)
         .encode_async(stream)
         .encode_async(stream)
         .await?;
         .await?;
 
 
-    if packet.payload.len() > 0 {
+    if !packet.payload.is_empty() {
         stream.write_all(&packet.payload).await?;
         stream.write_all(&packet.payload).await?;
     }
     }
     debug!(target: "net", "sent payload {} bytes", packet.payload.len() as u64);
     debug!(target: "net", "sent payload {} bytes", packet.payload.len() as u64);

+ 3 - 5
src/net/protocols/protocol_seed.rs

@@ -60,12 +60,10 @@ impl ProtocolSeed {
             Some(addr) => {
             Some(addr) => {
                 debug!(target: "net", "ProtocolSeed::send_own_address() addr={}", addr);
                 debug!(target: "net", "ProtocolSeed::send_own_address() addr={}", addr);
                 let addr = messages::AddrsMessage { addrs: vec![addr] };
                 let addr = messages::AddrsMessage { addrs: vec![addr] };
-                self.channel.clone().send(addr).await?;
-            }
-            None => {
-                // Do nothing if external address is not configured
+                Ok(self.channel.clone().send(addr).await?)
             }
             }
+            // Do nothing if external address is not configured
+            None => Ok(()),
         }
         }
-        Ok(())
     }
     }
 }
 }

+ 1 - 1
src/net/sessions/inbound_session.rs

@@ -111,7 +111,7 @@ impl InboundSession {
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
         let settings = self.p2p().settings().clone();
         let settings = self.p2p().settings().clone();
-        let hosts = self.p2p().hosts().clone();
+        let hosts = self.p2p().hosts();
 
 
         let protocol_ping = ProtocolPing::new(channel.clone(), settings.clone());
         let protocol_ping = ProtocolPing::new(channel.clone(), settings.clone());
         let protocol_addr = ProtocolAddress::new(channel, hosts).await;
         let protocol_addr = ProtocolAddress::new(channel, hosts).await;

+ 2 - 2
src/net/sessions/outbound_session.rs

@@ -67,7 +67,7 @@ impl OutboundSession {
         slot_number: u32,
         slot_number: u32,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        let connector = Connector::new(self.p2p().settings().clone());
+        let connector = Connector::new(self.p2p().settings());
 
 
         loop {
         loop {
             let addr = self.load_address(slot_number).await?;
             let addr = self.load_address(slot_number).await?;
@@ -160,7 +160,7 @@ impl OutboundSession {
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
         let settings = self.p2p().settings().clone();
         let settings = self.p2p().settings().clone();
-        let hosts = self.p2p().hosts().clone();
+        let hosts = self.p2p().hosts();
 
 
         let protocol_ping = ProtocolPing::new(channel.clone(), settings.clone());
         let protocol_ping = ProtocolPing::new(channel.clone(), settings.clone());
         let protocol_addr = ProtocolAddress::new(channel, hosts).await;
         let protocol_addr = ProtocolAddress::new(channel, hosts).await;

+ 1 - 1
src/net/sessions/seed_session.rs

@@ -38,7 +38,7 @@ impl SeedSession {
         let mut tasks = Vec::new();
         let mut tasks = Vec::new();
 
 
         for (i, seed) in settings.seeds.iter().enumerate() {
         for (i, seed) in settings.seeds.iter().enumerate() {
-            tasks.push(executor.spawn(self.clone().start_seed(i, seed.clone(), executor.clone())));
+            tasks.push(executor.spawn(self.clone().start_seed(i, *seed, executor.clone())));
         }
         }
 
 
         // This line loops through all the tasks and waits for them to finish.
         // This line loops through all the tasks and waits for them to finish.

+ 1 - 1
src/serial.rs

@@ -228,7 +228,7 @@ impl VarInt {
     /// Returns 1 for 0...0xFC, 3 for 0xFD...(2^16-1), 5 for 0x10000...(2^32-1),
     /// Returns 1 for 0...0xFC, 3 for 0xFD...(2^16-1), 5 for 0x10000...(2^32-1),
     /// and 9 otherwise.
     /// and 9 otherwise.
     #[inline]
     #[inline]
-    pub fn len(&self) -> usize {
+    pub fn length(&self) -> usize {
         match self.0 {
         match self.0 {
             0..=0xFC => 1,
             0..=0xFC => 1,
             0xFD..=0xFFFF => 3,
             0xFD..=0xFFFF => 3,

+ 3 - 2
src/service/bridge.rs

@@ -79,7 +79,7 @@ impl Bridge {
         let (rep, receiver) = async_channel::unbounded();
         let (rep, receiver) = async_channel::unbounded();
 
 
         executor
         executor
-            .spawn(self.listen_for_new_subscribtion(req.clone(), rep.clone()))
+            .spawn(self.listen_for_new_subscribtion(req, rep))
             .detach();
             .detach();
 
 
         BridgeSubscribtion { sender, receiver }
         BridgeSubscribtion { sender, receiver }
@@ -95,7 +95,8 @@ impl Bridge {
         let client = &self.clients.lock().await[&asset_id];
         let client = &self.clients.lock().await[&asset_id];
 
 
         match req.payload {
         match req.payload {
-            BridgeRequestsPayload::WatchRequest => { let sub = client.subscribe().await?;
+            BridgeRequestsPayload::WatchRequest => {
+                let sub = client.subscribe().await?;
                 let res = BridgeResponse {
                 let res = BridgeResponse {
                     error: 0,
                     error: 0,
                     payload: BridgeResponsePayload::WatchResponse(sub.secret_key, sub.public_key),
                     payload: BridgeResponsePayload::WatchResponse(sub.secret_key, sub.public_key),

+ 4 - 4
src/service/btc.rs

@@ -149,7 +149,7 @@ impl BtcClient {
             .map_err(|err| crate::Error::from(super::BtcFailed::from(err)))?;
             .map_err(|err| crate::Error::from(super::BtcFailed::from(err)))?;
         Ok(Self {
         Ok(Self {
             client: Arc::new(client),
             client: Arc::new(client),
-            network: network,
+            network,
         })
         })
     }
     }
 }
 }
@@ -243,7 +243,7 @@ impl Decodable for bitcoin::PrivateKey {
 #[derive(Debug)]
 #[derive(Debug)]
 pub enum BtcFailed {
 pub enum BtcFailed {
     NotEnoughValue(u64),
     NotEnoughValue(u64),
-    BadBTCAddress(String),
+    BadBtcAddress(String),
     ElectrumError(String),
     ElectrumError(String),
     BtcError(String),
     BtcError(String),
     DecodeAndEncodeError(String),
     DecodeAndEncodeError(String),
@@ -257,7 +257,7 @@ impl std::fmt::Display for BtcFailed {
             BtcFailed::NotEnoughValue(i) => {
             BtcFailed::NotEnoughValue(i) => {
                 write!(f, "There is no enough value {}", i)
                 write!(f, "There is no enough value {}", i)
             }
             }
-            BtcFailed::BadBTCAddress(ref err) => {
+            BtcFailed::BadBtcAddress(ref err) => {
                 write!(f, "Unable to create Electrum Client: {}", err)
                 write!(f, "Unable to create Electrum Client: {}", err)
             }
             }
             BtcFailed::ElectrumError(ref err) => write!(f, "could not parse BTC address: {}", err),
             BtcFailed::ElectrumError(ref err) => write!(f, "could not parse BTC address: {}", err),
@@ -279,7 +279,7 @@ impl From<crate::error::Error> for BtcFailed {
 
 
 impl From<bitcoin::util::address::Error> for BtcFailed {
 impl From<bitcoin::util::address::Error> for BtcFailed {
     fn from(err: bitcoin::util::address::Error) -> BtcFailed {
     fn from(err: bitcoin::util::address::Error) -> BtcFailed {
-        BtcFailed::BadBTCAddress(err.to_string())
+        BtcFailed::BadBtcAddress(err.to_string())
     }
     }
 }
 }
 impl From<electrum_client::Error> for BtcFailed {
 impl From<electrum_client::Error> for BtcFailed {

+ 15 - 22
src/service/gateway.rs

@@ -48,7 +48,7 @@ impl GatewayService {
     pub async fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
     pub async fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
         let service_name = String::from("GATEWAY DAEMON");
         let service_name = String::from("GATEWAY DAEMON");
 
 
-        let mut protocol = RepProtocol::new(self.addr.clone(), service_name.clone());
+        let mut protocol = RepProtocol::new(self.addr, service_name.clone());
 
 
         let (send, recv) = protocol.start().await?;
         let (send, recv) = protocol.start().await?;
 
 
@@ -90,23 +90,16 @@ impl GatewayService {
         publish_queue: async_channel::Sender<Vec<u8>>,
         publish_queue: async_channel::Sender<Vec<u8>>,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        loop {
-            match recv_queue.recv().await {
-                Ok(msg) => {
-                    let slabstore = self.slabstore.clone();
-                    let _ = executor
-                        .spawn(Self::handle_request(
-                            msg,
-                            slabstore,
-                            send_queue.clone(),
-                            publish_queue.clone(),
-                        ))
-                        .detach();
-                }
-                Err(_) => {
-                    break;
-                }
-            }
+        while let Ok(msg) = recv_queue.recv().await {
+            let slabstore = self.slabstore.clone();
+            let _ = executor
+                .spawn(Self::handle_request(
+                    msg,
+                    slabstore,
+                    send_queue.clone(),
+                    publish_queue.clone(),
+                ))
+                .detach();
         }
         }
         Ok(())
         Ok(())
     }
     }
@@ -130,7 +123,7 @@ impl GatewayService {
 
 
                 let mut reply = Reply::from(&request, GatewayError::NoError as u32, vec![]);
                 let mut reply = Reply::from(&request, GatewayError::NoError as u32, vec![]);
 
 
-                if let None = error {
+                if error.is_none() {
                     reply.set_error(GatewayError::UpdateIndex as u32);
                     reply.set_error(GatewayError::UpdateIndex as u32);
                 }
                 }
 
 
@@ -222,7 +215,7 @@ impl GatewayClient {
 
 
         if last_index > 0 {
         if last_index > 0 {
             for index in (local_last_index + 1)..(last_index + 1) {
             for index in (local_last_index + 1)..(last_index + 1) {
-                if let None = self.get_slab(index).await? {
+                if self.get_slab(index).await?.is_none() {
                     break;
                     break;
                 }
                 }
             }
             }
@@ -265,7 +258,7 @@ impl GatewayClient {
                 .request(GatewayCommand::PutSlab as u8, slab.clone(), handle_error)
                 .request(GatewayCommand::PutSlab as u8, slab.clone(), handle_error)
                 .await?;
                 .await?;
 
 
-            if let Some(_) = rep {
+            if rep.is_some() {
                 break;
                 break;
             }
             }
         }
         }
@@ -280,7 +273,7 @@ impl GatewayClient {
             .request(GatewayCommand::GetLastIndex as u8, vec![], handle_error)
             .request(GatewayCommand::GetLastIndex as u8, vec![], handle_error)
             .await?;
             .await?;
         if let Some(index) = rep {
         if let Some(index) = rep {
-            return Ok(deserialize(&index)?);
+            return deserialize(&index);
         }
         }
         Ok(0)
         Ok(0)
     }
     }

+ 3 - 6
src/service/reqrep.rs

@@ -44,7 +44,7 @@ impl RepProtocol {
         let (send_queue, recv_channel) = async_channel::unbounded::<(PeerId, Request)>();
         let (send_queue, recv_channel) = async_channel::unbounded::<(PeerId, Request)>();
         let (send_channel, recv_queue) = async_channel::unbounded::<(PeerId, Reply)>();
         let (send_channel, recv_queue) = async_channel::unbounded::<(PeerId, Reply)>();
 
 
-        let channels = (send_channel.clone(), recv_channel.clone());
+        let channels = (send_channel, recv_channel);
 
 
         RepProtocol {
         RepProtocol {
             addr,
             addr,
@@ -76,6 +76,7 @@ impl RepProtocol {
         let mut signals = Signals::new(&[SIGINT])?;
         let mut signals = Signals::new(&[SIGINT])?;
 
 
         let stop_task = executor.spawn(async move {
         let stop_task = executor.spawn(async move {
+            // TODO: Why?
             for _ in signals.forever() {
             for _ in signals.forever() {
                 stop_s.send(()).await?;
                 stop_s.send(()).await?;
                 break;
                 break;
@@ -325,11 +326,7 @@ impl Reply {
     }
     }
 
 
     pub fn has_error(&self) -> bool {
     pub fn has_error(&self) -> bool {
-        if self.error == 0 {
-            false
-        } else {
-            true
-        }
+        self.error != 0
     }
     }
 
 
     pub fn get_error(&self) -> u32 {
     pub fn get_error(&self) -> u32 {

+ 32 - 29
src/service/sol.rs

@@ -24,12 +24,12 @@ use std::collections::HashMap;
 use std::convert::TryFrom;
 use std::convert::TryFrom;
 use std::str::FromStr;
 use std::str::FromStr;
 
 
-//const RPC_SERVER: &'static str = "https://api.mainnet-beta.solana.com";
-//const WSS_SERVER: &'static str = "wss://api.mainnet-beta.solana.com";
-const RPC_SERVER: &'static str = "https://api.devnet.solana.com";
-const WSS_SERVER: &'static str = "wss://api.devnet.solana.com";
-//const RPC_SERVER: &'static str = "http://localhost:8899";
-//const WSS_SERVER: &'static str = "ws://localhost:8900";
+//const RPC_SERVER: &str = "https://api.mainnet-beta.solana.com";
+//const WSS_SERVER: &str = "wss://api.mainnet-beta.solana.com";
+const RPC_SERVER: &str = "https://api.devnet.solana.com";
+const WSS_SERVER: &str = "wss://api.devnet.solana.com";
+//const RPC_SERVER: &str = "http://localhost:8899";
+//const WSS_SERVER: &str = "ws://localhost:8900";
 
 
 #[derive(Serialize)]
 #[derive(Serialize)]
 struct SubscribeParams {
 struct SubscribeParams {
@@ -147,29 +147,32 @@ impl SolClient {
                 // get the keypair and old_balance from the subscriptions list
                 // get the keypair and old_balance from the subscriptions list
                 let (keypair, old_balance) = &self.subscriptions.lock().await[&owner_pubkey];
                 let (keypair, old_balance) = &self.subscriptions.lock().await[&owner_pubkey];
 
 
-                if new_bal > old_balance.to_owned() {
-                    let received_balance = new_bal - old_balance;
-
-                    self.send_to_main_account(&keypair)?;
-
-                    self.notify_channel
-                        .0
-                        .send(TokenNotification {
-                            secret_key: serialize(keypair),
-                            received_balance,
-                        })
-                        .await
-                        .map_err(|err| Error::from(err))?;
-
-                    self.unsubscribe(sub_id, &owner_pubkey).await?;
-
-                    debug!(
-                        target: "SOL BRIDGE",
-                        "Received {} lamports, to the pubkey: {} ",
-                        received_balance, owner_pubkey.to_string(),
-                    );
-                } else if new_bal < old_balance.to_owned() {
-                    self.unsubscribe(sub_id, &owner_pubkey).await?;
+                match new_bal > *old_balance {
+                    true => {
+                        let received_balance = new_bal - old_balance;
+
+                        self.send_to_main_account(&keypair)?;
+
+                        self.notify_channel
+                            .0
+                            .send(TokenNotification {
+                                secret_key: serialize(keypair),
+                                received_balance,
+                            })
+                            .await
+                            .map_err(|err| Error::from(err))?;
+
+                        self.unsubscribe(sub_id, &owner_pubkey).await?;
+
+                        debug!(
+                            target: "SOL BRIDGE",
+                            "Received {} lamports, to the pubkey: {} ",
+                            received_balance, owner_pubkey.to_string(),
+                        );
+                    }
+                    false => {
+                        self.unsubscribe(sub_id, &owner_pubkey).await?;
+                    }
                 }
                 }
             }
             }
         }
         }

+ 11 - 11
src/tx/builder.rs

@@ -39,9 +39,9 @@ pub struct TransactionBuilderOutputInfo {
 
 
 impl TransactionBuilder {
 impl TransactionBuilder {
     fn compute_remainder_blind(
     fn compute_remainder_blind(
-        clear_inputs: &Vec<PartialTransactionClearInput>,
-        input_blinds: &Vec<jubjub::Fr>,
-        output_blinds: &Vec<jubjub::Fr>,
+        clear_inputs: &[PartialTransactionClearInput],
+        input_blinds: &[jubjub::Fr],
+        output_blinds: &[jubjub::Fr],
     ) -> jubjub::Fr {
     ) -> jubjub::Fr {
         let mut total = jubjub::Fr::zero();
         let mut total = jubjub::Fr::zero();
 
 
@@ -86,7 +86,7 @@ impl TransactionBuilder {
         let mut input_blinds = vec![];
         let mut input_blinds = vec![];
         let mut signature_secrets = vec![];
         let mut signature_secrets = vec![];
         for input in &self.inputs {
         for input in &self.inputs {
-            input_blinds.push(input.note.valcom_blind.clone());
+            input_blinds.push(input.note.valcom_blind);
 
 
             let signature_secret: jubjub::Fr = jubjub::Fr::random(&mut OsRng);
             let signature_secret: jubjub::Fr = jubjub::Fr::random(&mut OsRng);
 
 
@@ -110,7 +110,7 @@ impl TransactionBuilder {
                 input.note.coin_blind,
                 input.note.coin_blind,
                 input.secret,
                 input.secret,
                 auth_path,
                 auth_path,
-                signature_secret.clone(),
+                signature_secret,
             );
             );
 
 
             // First we make the tx then sign after
             // First we make the tx then sign after
@@ -142,11 +142,11 @@ impl TransactionBuilder {
                 mint_params,
                 mint_params,
                 output.value,
                 output.value,
                 output.asset_id,
                 output.asset_id,
-                valcom_blind.clone(),
-                asset_commit_blind.clone(),
-                serial.clone(),
-                coin_blind.clone(),
-                output.public.clone(),
+                valcom_blind,
+                asset_commit_blind,
+                serial,
+                coin_blind,
+                output.public,
             );
             );
 
 
             // Encrypted note
             // Encrypted note
@@ -182,7 +182,7 @@ impl TransactionBuilder {
 
 
         let mut clear_inputs = vec![];
         let mut clear_inputs = vec![];
         for (input, info) in partial_tx.clear_inputs.into_iter().zip(self.clear_inputs) {
         for (input, info) in partial_tx.clear_inputs.into_iter().zip(self.clear_inputs) {
-            let secret = schnorr::SecretKey(info.signature_secret.clone());
+            let secret = schnorr::SecretKey(info.signature_secret);
             let signature = secret.sign(&unsigned_tx_data[..]);
             let signature = secret.sign(&unsigned_tx_data[..]);
             let input = TransactionClearInput::from_partial(input, signature);
             let input = TransactionClearInput::from_partial(input, signature);
             clear_inputs.push(input);
             clear_inputs.push(input);

+ 4 - 5
src/tx/mod.rs

@@ -58,9 +58,8 @@ impl Transaction {
     }
     }
 
 
     fn compute_pedersen_commit(value: jubjub::Fr, blind: &jubjub::Fr) -> jubjub::SubgroupPoint {
     fn compute_pedersen_commit(value: jubjub::Fr, blind: &jubjub::Fr) -> jubjub::SubgroupPoint {
-        let value_commit = (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR * value)
-            + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR * blind);
-        value_commit
+        (zcash_primitives::constants::VALUE_COMMITMENT_VALUE_GENERATOR * value)
+            + (zcash_primitives::constants::VALUE_COMMITMENT_RANDOMNESS_GENERATOR * blind)
     }
     }
 
 
     fn verify_asset_commitments(&self) -> bool {
     fn verify_asset_commitments(&self) -> bool {
@@ -121,13 +120,13 @@ impl Transaction {
         self.encode_without_signature(&mut unsigned_tx_data)
         self.encode_without_signature(&mut unsigned_tx_data)
             .expect("TODO handle this");
             .expect("TODO handle this");
         for (i, input) in self.clear_inputs.iter().enumerate() {
         for (i, input) in self.clear_inputs.iter().enumerate() {
-            let public = schnorr::PublicKey(input.signature_public.clone());
+            let public = schnorr::PublicKey(input.signature_public);
             if !public.verify(&unsigned_tx_data[..], &input.signature) {
             if !public.verify(&unsigned_tx_data[..], &input.signature) {
                 return Err(state::VerifyFailed::ClearInputSignature(i));
                 return Err(state::VerifyFailed::ClearInputSignature(i));
             }
             }
         }
         }
         for (i, input) in self.inputs.iter().enumerate() {
         for (i, input) in self.inputs.iter().enumerate() {
-            let public = schnorr::PublicKey(input.revealed.signature_public.clone());
+            let public = schnorr::PublicKey(input.revealed.signature_public);
             if !public.verify(&unsigned_tx_data[..], &input.signature) {
             if !public.verify(&unsigned_tx_data[..], &input.signature) {
                 return Err(state::VerifyFailed::InputSignature(i));
                 return Err(state::VerifyFailed::InputSignature(i));
             }
             }

+ 3 - 5
src/util.rs

@@ -8,14 +8,12 @@ use crate::{
     Result,
     Result,
 };
 };
 
 
-pub fn join_config_path(file: &PathBuf) -> Result<PathBuf> {
+pub fn join_config_path(file: &Path) -> Result<PathBuf> {
     let mut path = PathBuf::new();
     let mut path = PathBuf::new();
     let dfi_path = Path::new("darkfi");
     let dfi_path = Path::new("darkfi");
 
 
-    match dirs::config_dir() {
-        Some(v) => path.push(v),
-        // This should not fail on any modern OS
-        None => {}
+    if let Some(v) = dirs::config_dir() {
+        path.push(v);
     }
     }
 
 
     path.push(dfi_path);
     path.push(dfi_path);

+ 15 - 15
src/vm.rs

@@ -101,8 +101,8 @@ impl ZkVirtualMachine {
             match op {
             match op {
                 CryptoOperation::Set(self_, other) => {
                 CryptoOperation::Set(self_, other) => {
                     let other = match other {
                     let other = match other {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let self_ = match self_ {
                     let self_ = match self_ {
                         VariableRef::Aux(index) => &mut self.aux[*index],
                         VariableRef::Aux(index) => &mut self.aux[*index],
@@ -112,8 +112,8 @@ impl ZkVirtualMachine {
                 }
                 }
                 CryptoOperation::Mul(self_, other) => {
                 CryptoOperation::Mul(self_, other) => {
                     let other = match other {
                     let other = match other {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let self_ = match self_ {
                     let self_ = match self_ {
                         VariableRef::Aux(index) => &mut self.aux[*index],
                         VariableRef::Aux(index) => &mut self.aux[*index],
@@ -123,8 +123,8 @@ impl ZkVirtualMachine {
                 }
                 }
                 CryptoOperation::Add(self_, other) => {
                 CryptoOperation::Add(self_, other) => {
                     let other = match other {
                     let other = match other {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let self_ = match self_ {
                     let self_ = match self_ {
                         VariableRef::Aux(index) => &mut self.aux[*index],
                         VariableRef::Aux(index) => &mut self.aux[*index],
@@ -134,8 +134,8 @@ impl ZkVirtualMachine {
                 }
                 }
                 CryptoOperation::Sub(self_, other) => {
                 CryptoOperation::Sub(self_, other) => {
                     let other = match other {
                     let other = match other {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let self_ = match self_ {
                     let self_ = match self_ {
                         VariableRef::Aux(index) => &mut self.aux[*index],
                         VariableRef::Aux(index) => &mut self.aux[*index],
@@ -152,8 +152,8 @@ impl ZkVirtualMachine {
                 }
                 }
                 CryptoOperation::Divide(self_, other) => {
                 CryptoOperation::Divide(self_, other) => {
                     let other = match other {
                     let other = match other {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let self_ = match self_ {
                     let self_ = match self_ {
                         VariableRef::Aux(index) => &mut self.aux[*index],
                         VariableRef::Aux(index) => &mut self.aux[*index],
@@ -193,8 +193,8 @@ impl ZkVirtualMachine {
                 }
                 }
                 CryptoOperation::UnpackBits(value, start, end) => {
                 CryptoOperation::UnpackBits(value, start, end) => {
                     let value = match value {
                     let value = match value {
-                        VariableRef::Aux(index) => self.aux[*index].clone(),
-                        VariableRef::Local(index) => local_stack[*index].clone(),
+                        VariableRef::Aux(index) => self.aux[*index],
+                        VariableRef::Local(index) => local_stack[*index],
                     };
                     };
                     let (self_, start_index, end_index) = match start {
                     let (self_, start_index, end_index) = match start {
                         VariableRef::Aux(start_index) => match end {
                         VariableRef::Aux(start_index) => match end {
@@ -270,7 +270,7 @@ impl ZkVirtualMachine {
             match alloc_type {
             match alloc_type {
                 AllocType::Private => {}
                 AllocType::Private => {}
                 AllocType::Public => {
                 AllocType::Public => {
-                    let scalar = self.aux[*index].clone();
+                    let scalar = self.aux[*index];
                     publics.push((*index, scalar));
                     publics.push((*index, scalar));
                 }
                 }
             }
             }
@@ -301,7 +301,7 @@ impl ZkVirtualMachine {
     }
     }
 
 
     pub fn prove(&self) -> groth16::Proof<Bls12> {
     pub fn prove(&self) -> groth16::Proof<Bls12> {
-        let aux = self.aux.iter().map(|scalar| Some(scalar.clone())).collect();
+        let aux = self.aux.iter().map(|scalar| Some(*scalar)).collect();
         // Create an instance of our circuit (with the preimage as a witness).
         // Create an instance of our circuit (with the preimage as a witness).
         let circuit = ZkVmCircuit {
         let circuit = ZkVmCircuit {
             aux,
             aux,
@@ -319,7 +319,7 @@ impl ZkVirtualMachine {
         proof
         proof
     }
     }
 
 
-    pub fn verify(&self, proof: &groth16::Proof<Bls12>, public_values: &Vec<Scalar>) -> bool {
+    pub fn verify(&self, proof: &groth16::Proof<Bls12>, public_values: &[Scalar]) -> bool {
         let start = Instant::now();
         let start = Instant::now();
         let is_passed =
         let is_passed =
             groth16::verify_proof(self.verifying_key.as_ref().unwrap(), proof, public_values)
             groth16::verify_proof(self.verifying_key.as_ref().unwrap(), proof, public_values)

+ 1 - 1
src/vm_serial.rs

@@ -50,7 +50,7 @@ impl Encodable for ZkProof {
         let mut len = self
         let mut len = self
             .public
             .public
             .iter()
             .iter()
-            .map(|(k, v)| (k.clone(), v.clone()))
+            .map(|(k, v)| (k.clone(), *v))
             .collect::<Vec<_>>()
             .collect::<Vec<_>>()
             .encode(&mut s)?;
             .encode(&mut s)?;
         len += self.proof.encode(&mut s)?;
         len += self.proof.encode(&mut s)?;

+ 2 - 2
src/wallet/cashierdb.rs

@@ -6,7 +6,7 @@ use async_std::sync::Arc;
 use log::*;
 use log::*;
 use rusqlite::{named_params, params, Connection};
 use rusqlite::{named_params, params, Connection};
 
 
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
 
 
 pub type CashierDbPtr = Arc<CashierDb>;
 pub type CashierDbPtr = Arc<CashierDb>;
 
 
@@ -25,7 +25,7 @@ impl WalletApi for CashierDb {
 }
 }
 
 
 impl CashierDb {
 impl CashierDb {
-    pub fn new(path: &PathBuf, password: String) -> Result<CashierDbPtr> {
+    pub fn new(path: &Path, password: String) -> Result<CashierDbPtr> {
         debug!(target: "CASHIERDB", "new() Constructor called");
         debug!(target: "CASHIERDB", "new() Constructor called");
         Ok(Arc::new(Self {
         Ok(Arc::new(Self {
             path: path.to_owned(),
             path: path.to_owned(),

+ 2 - 2
src/wallet/walletdb.rs

@@ -12,7 +12,7 @@ use log::*;
 use rand::rngs::OsRng;
 use rand::rngs::OsRng;
 use rusqlite::{named_params, params, Connection};
 use rusqlite::{named_params, params, Connection};
 
 
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
 
 
 pub type WalletPtr = Arc<WalletDb>;
 pub type WalletPtr = Arc<WalletDb>;
 
 
@@ -38,7 +38,7 @@ impl WalletApi for WalletDb {
 }
 }
 
 
 impl WalletDb {
 impl WalletDb {
-    pub fn new(path: &PathBuf, password: String) -> Result<WalletPtr> {
+    pub fn new(path: &Path, password: String) -> Result<WalletPtr> {
         debug!(target: "WALLETDB", "new() Constructor called");
         debug!(target: "WALLETDB", "new() Constructor called");
         Ok(Arc::new(Self {
         Ok(Arc::new(Self {
             path: path.to_owned(),
             path: path.to_owned(),