Optimise to_network_msg: no need to clone to_sign

This commit is contained in:
Sosthene 2024-10-29 13:02:27 +01:00 committed by Nicolas Cantu
parent 6f5a8d778f
commit 8c4e35f302

View File

@ -238,17 +238,16 @@ impl Prd {
/// Generate the signed proof and serialize to send over the network /// Generate the signed proof and serialize to send over the network
pub fn to_network_msg(&self, sp_wallet: &SpWallet) -> Result<String> { pub fn to_network_msg(&self, sp_wallet: &SpWallet) -> Result<String> {
let spend_sk: SecretKey = sp_wallet.get_client().get_spend_key().try_into()?; let spend_sk: SecretKey = sp_wallet.get_client().get_spend_key().try_into()?;
let to_sign = self.clone(); // we sign the whole prd, incl the keys, for each recipient let mut to_sign = self.clone(); // we sign the whole prd, incl the keys, for each recipient
let message_hash = let message_hash =
AnkHash::Message(AnkMessageHash::from_message(to_sign.to_string().as_bytes())); AnkHash::Message(AnkMessageHash::from_message(to_sign.to_string().as_bytes()));
let proof = Proof::new(message_hash, spend_sk); let proof = Proof::new(message_hash, spend_sk);
let mut res = self.clone(); to_sign.proof = Some(proof);
res.proof = Some(proof);
Ok(res.to_string()) Ok(to_sign.to_string())
} }
pub fn to_string(&self) -> String { pub fn to_string(&self) -> String {