Skip to content

Commit

Permalink
chore: concurrently fetch picture and banner
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Dec 12, 2024
1 parent 6e29389 commit c76b33a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions extensions/warp-ipfs/src/store/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl RootDocument {
}
}

async fn resolve_to_img_doc(ipfs: &Ipfs, cid: Cid) -> Result<(), Error> {
async fn resolve_to_img_doc(ipfs: Ipfs, cid: Cid) -> Result<(), Error> {
let dag: ImageDag = ipfs.get_dag(cid).deserialized().await?;
if dag.size > MAX_IMAGE_SIZE as _ {
return Err(Error::InvalidLength {
Expand All @@ -469,19 +469,23 @@ async fn resolve_verify_image(ipfs: &Ipfs, identity_document: &IdentityDocument)
.profile_picture
.ok_or(Error::Other),
)
.and_then(|cid| async move { resolve_to_img_doc(ipfs, cid).await })
.await;
.and_then(|cid| {
let ipfs = ipfs.clone();
async move { resolve_to_img_doc(ipfs, cid).await }
});

let _fut_banner = futures::future::ready(
identity_document
.metadata
.profile_banner
.ok_or(Error::Other),
)
.and_then(|cid| async move { resolve_to_img_doc(ipfs, cid).await })
.await;
.and_then(|cid| {
let ipfs = ipfs.clone();
async move { resolve_to_img_doc(ipfs, cid).await }
});

// _ = tokio::join!(fut_picture, fut_banner);
_ = tokio::join!(_fut_picture, _fut_banner);
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
Expand Down

0 comments on commit c76b33a

Please sign in to comment.