Skip to content

Commit

Permalink
Merge pull request #60 from rklaehn/fix-async
Browse files Browse the repository at this point in the history
actually use async when the async feature is enabled
  • Loading branch information
Nuhvi authored Apr 16, 2024
2 parents e84a1bd + ad940d2 commit 3972237
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkarr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ impl PkarrClient {
/// before storing the signed packet to them, so it may take few seconds.
pub async fn publish(&self, signed_packet: &SignedPacket) -> Result<StoreQueryMetdata> {
let item: MutableItem = signed_packet.into();
self.dht.put_mutable(item).map_err(Error::MainlineError)
self.dht
.clone()
.as_async()
.put_mutable(item)
.await
.map_err(Error::MainlineError)
}

#[cfg(all(feature = "dht", not(feature = "async")))]
Expand All @@ -235,7 +240,7 @@ impl PkarrClient {
pub async fn resolve(&self, public_key: PublicKey) -> Option<SignedPacket> {
let mut response = self.dht.get_mutable(public_key.as_bytes(), None);

for res in &mut response {
while let Some(res) = response.next_async().await {
let signed_packet: Result<SignedPacket> = res.item.try_into();
if let Ok(signed_packet) = signed_packet {
return Some(signed_packet);
Expand Down Expand Up @@ -275,7 +280,7 @@ impl PkarrClient {

let mut most_recent: Option<SignedPacket> = None;

for next in &mut response {
while let Some(next) = response.next_async().await {
let next_packet: Result<SignedPacket> = next.item.try_into();
if let Ok(next_packet) = next_packet {
if let Some(most_recent) = &most_recent {
Expand Down

0 comments on commit 3972237

Please sign in to comment.