Browse Source

drk: Only mark spent coins if necessary.

parazyd 3 years ago
parent
commit
ce71169a8a
1 changed files with 5 additions and 3 deletions
  1. 5 3
      bin/drk/src/rpc_blockchain.rs

+ 5 - 3
bin/drk/src/rpc_blockchain.rs

@@ -212,9 +212,11 @@ impl Drk {
         self.put_tree(&tree).await?;
         eprintln!("Merkle tree written successfully");
 
-        eprintln!("Marking spent coins");
-        self.mark_spent_coins(nullifiers).await?;
-        eprintln!("Spent coins marked successfully");
+        if !nullifiers.is_empty() {
+            eprintln!("Found {} spent coins, marking as spent", nullifiers.len());
+            self.mark_spent_coins(nullifiers).await?;
+            eprintln!("Spent coins marked successfully");
+        }
 
         // This is the SQL query we'll be executing to insert coins into the wallet
         let query = format!(