From bd9fd8afbd6178c860f8849c42228368d4b3d850 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Tue, 13 Aug 2024 14:55:54 -0400 Subject: [PATCH] nostr: avoid `PublicKey` copy in NIP-05 module Signed-off-by: Yuki Kishimoto --- crates/nostr/src/nips/nip05.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/nostr/src/nips/nip05.rs b/crates/nostr/src/nips/nip05.rs index d7699180b..980c89cd0 100644 --- a/crates/nostr/src/nips/nip05.rs +++ b/crates/nostr/src/nips/nip05.rs @@ -102,7 +102,7 @@ fn get_key_from_json(json: &Value, name: &str) -> Option { } #[inline] -fn get_relays_from_json(json: &Value, pk: PublicKey) -> Vec { +fn get_relays_from_json(json: &Value, pk: &PublicKey) -> Vec { json.get("relays") .and_then(|relays| relays.get(pk.to_hex())) .and_then(|value| serde_json::from_value(value.clone()).ok()) @@ -110,7 +110,7 @@ fn get_relays_from_json(json: &Value, pk: PublicKey) -> Vec { } #[inline] -fn get_nip46_relays_from_json(json: &Value, pk: PublicKey) -> Vec { +fn get_nip46_relays_from_json(json: &Value, pk: &PublicKey) -> Vec { json.get("nip46") .and_then(|relays| relays.get(pk.to_hex())) .and_then(|value| serde_json::from_value(value.clone()).ok()) @@ -178,8 +178,8 @@ where let (json, name) = make_req(nip05.as_ref(), _proxy).await?; let public_key: PublicKey = get_key_from_json(&json, name).ok_or(Error::ImpossibleToVerify)?; - let relays: Vec = get_relays_from_json(&json, public_key); - let nip46: Vec = get_nip46_relays_from_json(&json, public_key); + let relays: Vec = get_relays_from_json(&json, &public_key); + let nip46: Vec = get_nip46_relays_from_json(&json, &public_key); Ok(Nip05Profile { public_key,