Jelajahi Sumber

contract/money: Implement std::hash::Hash for OwnCoin

parazyd 2 tahun lalu
induk
melakukan
2f7c4b4e17
1 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 8 0
      src/contract/money/src/client/mod.rs

+ 8 - 0
src/contract/money/src/client/mod.rs

@@ -26,6 +26,8 @@
 //! the necessary objects provided by the caller. This is intentional, so we
 //! are able to abstract away any wallet interfaces to client implementations.
 
+use std::hash::{Hash, Hasher};
+
 use darkfi_sdk::{
     bridgetree,
     crypto::{BaseBlind, Blind, FuncId, ScalarBlind, SecretKey},
@@ -103,6 +105,12 @@ pub struct OwnCoin {
     pub leaf_position: bridgetree::Position,
 }
 
+impl Hash for OwnCoin {
+    fn hash<H: Hasher>(&self, state: &mut H) {
+        self.coin.inner().to_repr().hash(state);
+    }
+}
+
 pub fn compute_remainder_blind(
     clear_inputs: &[crate::model::ClearInput],
     input_blinds: &[ScalarBlind],