-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Feature request to check if a connection to a peer already exists #6091
Comments
Thanks for the suggestion. At the moment, the only way to do this is to parse |
@remmerw What is the proposed interface for this change? I think this is a great introductory task if we can provide enough actionable definition. |
@michaelavila My assumption is that the command |
@remmerw apologies, I misunderstood. Do you have an interface proposal? You want to do more than just check that the peer is in your list, right? You want to do something to determine if the connection to that peer is still valid? Maybe by acknowledging some kind of message? |
@michaelavila Yes, that is true, just checking if the peer is in the list, might be not be the "best" solution. |
@remmerw understood. Polling the output of |
Ok, after a quick evaluation of the source code. Interface : .... Implementation : *** NEW *** func (api *SwarmAPI) IsConnected(ctx context.Context, pi pstore.PeerInfo) (bool, error) { About the implementation I am not 100% sure if all is correct (but I hope you get the idea) For me right now, such solution only on Core API level is fine (no need to add to HTTP API ) I would be very grateful to have such a functionality |
@remmerw what are the next steps for this approach? Can you write the test that this code you've posted will pass? Have you attempted to use the change you're proposing yet? |
@michaelavila I have implemented it and it works (and also it is a little bit faster) but I have to admit |
@remmerw do you want to submit the changes you're using now as a PR? The notification-based change can be discussed further in this issue in the meantime. |
@michaelavila Nope no intension to submit it, The solution which I thought was a solution, should be called correctly "IsConnectedOrNot" instead of "IsConnected" [wich make no sense] |
Version information:
All Versions
Type:
"feature": "ipfs swarm connect" with an option to check if a connection to a peer exists (but not open a new connection in case it does not exists) -> maybe a similar option exists already, but I was not able to find it)
Description:
Currently I use the function "ipfs swarm peers" to check if a connection to a peer exists.
But parsing all connected peers might be to not appropriate.
The text was updated successfully, but these errors were encountered: