Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
refactor(kad): make
Kademlia::add_address
return Result #4280base: master
Are you sure you want to change the base?
refactor(kad): make
Kademlia::add_address
return Result #4280Changes from 3 commits
aef9507
60c25b7
82133f3
fd1b37c
992cddf
a650274
a117e25
11f3a17
c79058b
5fe3128
64f3243
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Sorry that this is only coming up now but I just realized that we have a feature coming up that conflicts with this idea. It is here: #4371
This function will likely be deprecated in favor of a general
add_address_of_peer
function onSwarm
. This means, we won't be able to return a specific error there!In fact, we won't be able to return anything at all.
Thus, I think we should actually change this PR into preparing this API for the above change. Here is what I'd suggest but I am interested to hear your and @mxinden's opinion:
RoutingUpdate
as deprecated but retain the current functionality.KademliaEvent::RoutingUpdated
, even for the immediateRoutingUpdate::Success
casedebug_assert
to theSelfEntry
case. If we attempt to add ourselves to the routing table, this is a programmer bug and should not happen. We can ignore that in production (but should probably emit a fatwarn!
), hence thedebug_assert
.This makes this a backwards-compatible change and we can land it right away.
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 missed this as well. I am sorry @arsenron.
Suggestion overall sounds good to me.
Panicing on invalid user input seems rather drastic. Wouldn't a
warn!
suffice in all cases? Also, not as part of this pull request, we should handle theSelfEntry
on thelibp2p-swarm
level. We should at least log when aNetworkBehaviour
or user (viaSwarm::add_address_of_peer
) wants to report a an external address of a remote peer where that peer is actually the local peer.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.
The warn will be there in all cases but pancking in debug builds is fine, no? You didn't validate your inputs correctly in that case.
True, as part of #4371, we should probably not forward any of these events! cc @StemCll
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.
@arsenron I fixed the merge conflicts for you. Are you still interested in working on this given the above insight?
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.
@thomaseizinger sorry, little busy now, but I will check it a bit later