-
Notifications
You must be signed in to change notification settings - Fork 975
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
Add a method to Kademlia to get detailed information about peers #1056
Conversation
Looks good, but the code duplication because of |
I can change it, but I feel that having a query interface that takes |
Another argument in favour of I don't think
I don't see how. In the worst case scenario a user will not be able to use the API that requires |
Should it? I would expect the new query methods to just return a current snapshot of the table.
I agree that, in terms of information returned both should return the same status. My understanding of
I think this argument couples the design of the interface with its use. Agreed, if kad is only used in |
That's the issue that I don't know how to properly solve in terms of the API. The situation is: we tell the k-bucket "if node A hasn't responded in 20 seconds, then replace it with B". Then if we immediately call That's a bad way to do it, and in my opinion it should be changed to have some explicit |
That looks like something more complex than the |
Yes! |
I'm trying to replace Alternatively, what we can do to avoid code redundancy is make the /// Represents an entry in a k-bucket.
pub struct EntryInKbucketConn<'a, TParent, TPeerId> {
//parent: &'a mut KBucketsTable<TPeerId, TVal>,
parent: TParent,
peer_id: &'a TPeerId,
} This is relatively straightforward, but then type signatures look cumbersome: /// Returns an iterator to all the peer IDs in the bucket, including the pending nodes.
pub fn entries<'a>(&'a self) -> impl 'a + Iterator<Item = Entry<'a, &'a KBucketsTable<TPeerId, TVal>, TPeerId>>{ |
Ah yeah, I didn't anticipate this. I guess that this is a good motivation for restoring the code duplication. |
This is very much out of date but I believe most if not all of what was done here is already provided by the refactored APIs (in particular since #1117 which included substantial changes). I suggest to close this PR and update the associated ticket with details about what is still missing in the context of the current API. |
Addresses #1003
This PR adds
peer_state()
andpeer_states()
toKademlia
and allows to query their state within the table. I guess issue #1003 suggests also being able to query values stored in Kademlia but if that is necessary, I would address that in a separate PR.