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(iroh-p2p): implement full local lookup #537

Merged
merged 2 commits into from
Nov 22, 2022
Merged

fix(iroh-p2p): implement full local lookup #537

merged 2 commits into from
Nov 22, 2022

Conversation

ramfox
Copy link
Contributor

@ramfox ramfox commented Nov 21, 2022

We were previously only returning the peer id, external addrs, and listening addrs. We now return the same content as performing a lookup on a remote peer.

closes n0-computer/beetle#70

We were previously only returning the peer id, external addrs, and
listening addrs. We now return the same content as performing a lookup
on a remote peer.
@ramfox ramfox added c-p2p fix Fixes a bug labels Nov 21, 2022
@ramfox ramfox added this to the v0.1.1 milestone Nov 21, 2022
@ramfox ramfox self-assigned this Nov 21, 2022
Comment on lines 192 to +214
fn poll(
&mut self,
_cx: &mut Context<'_>,
_params: &mut impl PollParameters,
params: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>> {
// TODO(ramfox):
// We can only get the supported protocols of the local node by examining the
// `PollParameters`, which mean you can only get the supported protocols by examining the
// `PollParameters` in this method (`poll`) of a network behaviour.
// I injected this responsibility in the `peer_manager`, because it's the only "simple"
// network behaviour we have implemented.
// There is an issue up to remove `PollParameters`, and a discussion into how to instead
// get the `supported_protocols` of the node:
// https://github.com/libp2p/rust-libp2p/issues/3124
// When that is resolved, we can hopefully remove this responsibility from the `peer_manager`,
// where it, frankly, doesn't belong.
if self.supported_protocols.is_empty() {
self.supported_protocols = params
.supported_protocols()
.map(|p| String::from_utf8_lossy(&p).to_string())
.collect();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dignifiedquire would specifically like your eyes on this.

I gave some rationale as to why this is how I decided to proceed, but I'm aware this is an inelegant solution to an inelegant problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me, we can just update this code once libp2p provides a better method

@ramfox ramfox merged commit 0c388b9 into main Nov 22, 2022
@ramfox ramfox deleted the ramfox/fix_lookup branch November 22, 2022 14:15
ppodolsky pushed a commit to izihawa/iroh that referenced this pull request Nov 23, 2022
We were previously only returning the peer id, external addrs, and
listening addrs. We now return the same content as performing a lookup
on a remote peer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

running iroh p2p lookup gives Protocols (0) every time
2 participants