Skip to content

Commit

Permalink
feat(pubky): return cached packets if nothing else is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Oct 7, 2024
1 parent 5a1a3da commit 76e9520
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pubky/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reqwest::{RequestBuilder, Response};
use tokio::sync::oneshot;
use url::Url;

use pkarr::{Keypair, PkarrClientAsync};
use pkarr::{mainline::MutableItem, Keypair, PkarrClientAsync};

use ::pkarr::{mainline::dht::Testnet, PkarrClient, PublicKey, SignedPacket};

Expand Down Expand Up @@ -240,7 +240,10 @@ impl PubkyClient {
&self,
public_key: &PublicKey,
) -> Result<Option<SignedPacket>> {
Ok(self.pkarr.resolve(public_key).await?)
Ok(self.pkarr.resolve(public_key).await?.or(self
.pkarr
.cache()
.get(&MutableItem::target_from_key(public_key.as_bytes(), &None))))
}

pub(crate) async fn pkarr_publish(&self, signed_packet: &SignedPacket) -> Result<()> {
Expand Down

0 comments on commit 76e9520

Please sign in to comment.