Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 78a9b0d

Browse files
bors[bot]ljedrz
andauthored
Merge #374
374: Fix 2 issues triggered with the dht_popular_content_discovery test r=aphelionz a=ljedrz This is an `#[ignore]`d test due to it using the global network, but it's a practical debugging tool regardless; this time it helped fix 2 issues: - the handling of `Multiaddr`s ending with `/p2p-circuit` - searching for `Block` providers using the full `Cid` instead of just the `Multiaddr` (we've noticed this before, but it got lost in the TODOs 😛) Co-authored-by: ljedrz <ljedrz@gmail.com>
2 parents 070abe5 + a7d342b commit 78a9b0d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/p2p/addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ impl TryFrom<Multiaddr> for MultiaddrWithPeerId {
112112
// is unexpected; it is hard to trigger, hence this debug-only assertion so we might be
113113
// able to catch it sometime during tests
114114
debug_assert!(
115-
matches!(multiaddr.iter().last(), Some(Protocol::P2p(_))),
115+
matches!(multiaddr.iter().last(), Some(Protocol::P2p(_)) | Some(Protocol::P2pCircuit)),
116116
"unexpected Multiaddr format: {}",
117117
multiaddr
118118
);
119119

120120
let multiaddr = MultiaddrWithoutPeerId(
121121
multiaddr
122122
.into_iter()
123-
.filter(|p| !matches!(p, Protocol::P2p(_)))
123+
.filter(|p| !matches!(p, Protocol::P2p(_) | Protocol::P2pCircuit))
124124
.collect(),
125125
);
126126
let peer_id =

src/p2p/behaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ impl<Types: IpfsTypes> Behaviour<Types> {
471471
// FIXME: it would be best if get_providers is called only in case the already connected
472472
// peers don't have it
473473
pub fn want_block(&mut self, cid: Cid) {
474-
let key = cid.to_bytes();
474+
let key = cid.hash().as_bytes().to_owned();
475475
self.kademlia.get_providers(key.into());
476476
self.bitswap.want_block(cid, 1);
477477
}

0 commit comments

Comments
 (0)