Parcourir la source

Clean up some clippy lints.

parazyd il y a 4 ans
Parent
commit
a47505b427

+ 2 - 2
src/bin/tx.rs

@@ -147,7 +147,7 @@ fn main() -> Result<()> {
 
     // Now spend
     let (coin, note) = &state.own_coins[0];
-    let node = MerkleNode(coin.0.clone());
+    let node = MerkleNode(coin.0);
     let (leaf_position, merkle_path) = state.tree.authentication_path(&node).unwrap();
 
     let builder = tx::TransactionBuilder {
@@ -156,7 +156,7 @@ fn main() -> Result<()> {
             leaf_position,
             merkle_path,
             secret: keypair.secret,
-            note: note.clone(),
+            note: *note,
         }],
         outputs: vec![tx::TransactionBuilderOutputInfo {
             value: 110,

+ 1 - 1
src/circuit/spend_contract.rs

@@ -451,7 +451,7 @@ impl Circuit<pallas::Base> for SpendContract {
 
         let sig_pub = {
             let nullifier_k = OrchardFixedBases::NullifierK;
-            let nullifier_k = FixedPoint::from_inner(ecc_chip.clone(), nullifier_k);
+            let nullifier_k = FixedPoint::from_inner(ecc_chip, nullifier_k);
             nullifier_k.mul_base_field(layouter.namespace(|| "[x_s] Nullifier"), sig_secret)?
         };
 

+ 4 - 4
src/client.rs

@@ -90,7 +90,7 @@ impl Client {
         }
 
         // TODO: Think about multiple keypairs
-        let main_keypair = wallet.get_keypairs().await?[0].clone();
+        let main_keypair = wallet.get_keypairs().await?[0];
         info!("Main keypair: {}", bs58::encode(&serialize(&main_keypair.public)).into_string());
 
         debug!("Creating GatewayClient");
@@ -127,7 +127,7 @@ impl Client {
 
         if clear_input {
             // TODO: FIXME:
-            let signature_secret = self.main_keypair.clone().secret;
+            let signature_secret = self.main_keypair.secret;
             let input = tx::TransactionBuilderClearInputInfo { value, token_id, signature_secret };
             clear_inputs.push(input);
         } else {
@@ -151,7 +151,7 @@ impl Client {
                     leaf_position,
                     merkle_path,
                     secret: own_coin.secret,
-                    note: own_coin.note.clone(),
+                    note: own_coin.note,
                 };
 
                 inputs.push(input);
@@ -307,7 +307,7 @@ impl Client {
         debug!("Start subscriber for darkfid");
         let gateway_slabs_sub = self.gateway.start_subscriber(executor.clone()).await?;
 
-        let secret_key = self.main_keypair.secret.clone();
+        let secret_key = self.main_keypair.secret;
         let wallet = self.wallet.clone();
 
         let task: smol::Task<Result<()>> = executor.spawn(async move {

+ 1 - 1
src/crypto/keypair.rs

@@ -22,7 +22,7 @@ pub struct Keypair {
 
 impl Keypair {
     pub fn new(secret: SecretKey) -> Self {
-        let public = PublicKey::from_secret(secret.clone());
+        let public = PublicKey::from_secret(secret);
         Keypair { secret, public }
     }
 

+ 1 - 1
src/crypto/mint_proof.rs

@@ -123,7 +123,7 @@ pub fn create_mint_proof(
 
     let start = Instant::now();
     let public_inputs = revealed.make_outputs();
-    let proof = Proof::create(&pk, &[c], &public_inputs)?;
+    let proof = Proof::create(pk, &[c], &public_inputs)?;
     debug!("Prove: [{:?}]", start.elapsed());
 
     Ok((proof, revealed))

+ 1 - 1
src/crypto/note.rs

@@ -101,7 +101,7 @@ impl Decodable for EncryptedNote {
 
 impl EncryptedNote {
     pub fn decrypt(&self, secret: &SecretKey) -> Result<Note> {
-        let shared_secret = sapling_ka_agree(&secret, &self.ephem_public);
+        let shared_secret = sapling_ka_agree(secret, &self.ephem_public);
         let key = kdf_sapling(&shared_secret, &self.ephem_public);
 
         let mut plaintext = [0; ENC_CIPHERTEXT_SIZE];

+ 2 - 2
src/crypto/spend_proof.rs

@@ -157,7 +157,7 @@ pub fn create_spend_proof(
         secret,
         leaf_position,
         merkle_path.clone(),
-        signature_secret.clone(),
+        signature_secret,
     );
 
     let merkle_path: Vec<pallas::Base> = merkle_path.iter().map(|node| node.0).collect();
@@ -178,7 +178,7 @@ pub fn create_spend_proof(
 
     let start = Instant::now();
     let public_inputs = revealed.make_outputs();
-    let proof = Proof::create(&pk, &[c], &public_inputs)?;
+    let proof = Proof::create(pk, &[c], &public_inputs)?;
     debug!("Prove: [{:?}]", start.elapsed());
 
     Ok((proof, revealed))

+ 2 - 2
src/state.rs

@@ -156,7 +156,7 @@ impl State {
 
                     let own_coin = OwnCoin {
                         coin,
-                        note: note.clone(),
+                        note,
                         secret: *secret,
                         // witness: witness.clone(),
                         nullifier,
@@ -190,7 +190,7 @@ impl State {
 impl ProgramState for State {
     fn is_valid_cashier_public_key(&self, public: &PublicKey) -> bool {
         debug!("Check if it is a valid cashier public key");
-        self.public_keys.contains(&public)
+        self.public_keys.contains(public)
     }
 
     fn is_valid_merkle(&self, merkle_root: &MerkleNode) -> bool {

+ 1 - 1
src/tx/builder.rs

@@ -104,7 +104,7 @@ impl TransactionBuilder {
                 input.secret,
                 input.leaf_position,
                 input.merkle_path,
-                signature_secret.clone(),
+                signature_secret,
             )?;
 
             // First we make the tx then sign after

+ 4 - 4
src/wallet/walletdb.rs

@@ -308,14 +308,14 @@ mod tests {
         let note = Note {
             serial,
             value: v,
-            token_id: t.clone(),
+            token_id: *t,
             coin_blind: DrkCoinBlind::random(&mut OsRng),
             value_blind: DrkValueBlind::random(&mut OsRng),
         };
 
         let coin = Coin(pallas::Base::random(&mut OsRng));
-        let nullifier = Nullifier::new(s.clone(), serial);
-        OwnCoin { coin, note, secret: s.clone(), nullifier }
+        let nullifier = Nullifier::new(*s, serial);
+        OwnCoin { coin, note, secret: *s, nullifier }
     }
 
     #[async_std::test]
@@ -359,7 +359,7 @@ mod tests {
         assert_eq!(balances.list[3].token_id, token_id);
 
         // get_keypairs()
-        let keypair_r = wallet.get_keypairs().await?[0].clone();
+        let keypair_r = wallet.get_keypairs().await?[0];
         assert_eq!(keypair, keypair_r);
 
         // get_own_coins()