-
Notifications
You must be signed in to change notification settings - Fork 161
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
iroh p2p peers
: command to list peers
#397
Conversation
4a76890
to
e655b10
Compare
fn display_peers(peers: HashMap<PeerId, Vec<Multiaddr>>) { | ||
// let mut pid_str: String; | ||
for (peer_id, addrs) in peers { | ||
if let Some(addr) = addrs.first() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just grabbing the first address, which I'm doubtful is actually the address we're connected to. We should make sure the addresses listed here are actually connected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a rule of thumb for this in lookup
as well: some entries return 20+ addrs, and that's... not necessary.
For the lookup of the currect peer, we can be more comfortable just displaying the first 5 (or whatever number we choose), because according to the docs they rank the external_addrs
that we can be dialed at, but like you mention, we don't have that luxury here, or for the other lookup
commands.
But also, we may want to pair this down. Maybe you use p2p peers
to just get a list of the peer ids (not peer_ids and addrs), and use p2p lookup PEER_ID
to investigate possible addresses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving this, but left 2 comments you can take or leave!
iroh-api/src/error.rs
Outdated
@@ -0,0 +1,27 @@ | |||
use std::io; | |||
use thiserror::Error as ThisError; | |||
// use std::error::Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you gotten the error talk from dig yet? don't want to get in trouble for approving thiserror
usage on top of anyhow
usage 🤣
e655b10
to
7420cdf
Compare
@@ -69,6 +71,13 @@ impl P2p for ClientP2p { | |||
} | |||
.map_err(|e| map_service_error("p2p", e)) | |||
} | |||
|
|||
async fn peers(&self) -> Result<HashMap<PeerId, Vec<Multiaddr>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer BTreeMap, less random...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. I'll make a note in a follow-up issue
closes n0-computer/beetle#127 |
builds on #402