Răsfoiți Sursa

node: Minor cleanup.

parazyd 4 ani în urmă
părinte
comite
83138dec07
3 a modificat fișierele cu 15 adăugiri și 14 ștergeri
  1. 0 3
      src/node/client.rs
  2. 12 8
      src/tx/mod.rs
  3. 3 3
      src/wallet/walletdb.rs

+ 0 - 3
src/node/client.rs

@@ -141,9 +141,6 @@ impl Client {
         state_transition(state, tx.clone())?;
         debug!("build_slab_from_tx(): Successful state transition");
 
-        debug!("build_slab_from_tx(): Broadcasting transaction");
-        debug!("build_slab_from_tx(): Broadcasted successfully");
-
         Ok((tx, coins))
     }
 

+ 12 - 8
src/tx/mod.rs

@@ -87,20 +87,24 @@ impl Transaction {
 
         // Add values from the inputs
         for (i, input) in self.inputs.iter().enumerate() {
-            if verify_burn_proof(burn_vk, &input.burn_proof, &input.revealed).is_err() {
-                error!("tx::verify(): Failed to verify burn proof {}", i);
-                return Err(VerifyFailed::BurnProof(i))
+            match verify_burn_proof(burn_vk, &input.burn_proof, &input.revealed) {
+                Ok(()) => valcom_total += &input.revealed.value_commit,
+                Err(e) => {
+                    error!("tx::verify(): Failed to verify burn proof {}: {}", i, e);
+                    return Err(VerifyFailed::BurnProof(i))
+                }
             }
-            valcom_total += &input.revealed.value_commit;
         }
 
         // Subtract values from the outputs
         for (i, output) in self.outputs.iter().enumerate() {
-            if verify_mint_proof(mint_vk, &output.mint_proof, &output.revealed).is_err() {
-                error!("tx::verify(): Failed to verify mint proof {}", i);
-                return Err(VerifyFailed::MintProof(i))
+            match verify_mint_proof(mint_vk, &output.mint_proof, &output.revealed) {
+                Ok(()) => valcom_total -= &output.revealed.value_commit,
+                Err(e) => {
+                    error!("tx::verify(): Failed to verify mint proof {}: {}", i, e);
+                    return Err(VerifyFailed::MintProof(i))
+                }
             }
-            valcom_total -= &output.revealed.value_commit;
         }
 
         // If the accumulator is not back in its initial state,

+ 3 - 3
src/wallet/walletdb.rs

@@ -232,15 +232,15 @@ impl WalletDb {
     }
 
     pub async fn put_tree(&self, tree: &BridgeTree<MerkleNode, 32>) -> Result<()> {
-        debug!("Attempting to write merkle tree");
+        debug!("put_tree(): Attempting to write merkle tree");
         let mut conn = self.conn.acquire().await?;
 
         let tree_bytes = bincode::serialize(tree)?;
 
-        debug!("Deleting old row");
+        debug!("put_tree(): Deleting old row");
         sqlx::query("DELETE FROM tree;").execute(&mut conn).await?;
 
-        debug!("Inserting new tree");
+        debug!("put_tree(): Inserting new tree");
         sqlx::query("INSERT INTO tree (tree) VALUES (?1);")
             .bind(tree_bytes)
             .execute(&mut conn)