Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate peer id in ipfs addr #175

Merged
merged 1 commit into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions operator/src/network/ipfs_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, bail, Result};
use async_trait::async_trait;
use keramik_common::peer_info::IpfsPeerInfo;
use multiaddr::{multihash::Multihash, Multiaddr, Protocol};
use multiaddr::Multiaddr;
use serde::Deserialize;

/// Define the behavior we consume from the IPFS RPC API.
Expand Down Expand Up @@ -47,10 +47,6 @@ impl IpfsRpcClient for HttpRpcClient {
addresses: Vec<String>,
}
let data: Response = resp.json().await?;
let hash = Multihash::from_bytes(&multibase::Base::Base58Btc.decode(data.id.clone())?)?;
let peer_id = libp2p_identity::PeerId::from_multihash(hash)
.map_err(|e| anyhow!("failed to build multiash: {:?}", e))?;
let p2p_proto = Protocol::P2p(peer_id);
// We expect to find at least one non loop back address
let p2p_addrs = data
.addresses
Expand All @@ -63,11 +59,7 @@ impl IpfsRpcClient for HttpRpcClient {
_ => false,
})
})
// Add peer id to multiaddrs
.map(|mut addr| {
addr.push(p2p_proto.clone());
addr.to_string()
})
.map(|addr| addr.to_string())
.collect::<Vec<String>>();

if !p2p_addrs.is_empty() {
Expand Down
Loading