-
Notifications
You must be signed in to change notification settings - Fork 223
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 example of a find peer query using go-kademlia #865
Conversation
qSubs map[query.QueryID]chan<- kad.Response[key.Key256, ma.Multiaddr] | ||
qSubsLk sync.RWMutex | ||
qSubCnt uint64 |
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 still think this would better handled in go-kademlia
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.
Yeah it would be nicer but the compromise is that the logic for stopping the query in the event loop has to be injected
ch, ok := d.qSubs[tev.QueryID] | ||
if !ok { | ||
// we have lost the query waiter somehow | ||
d.kad.StopQuery(ctx, tev.QueryID) |
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.
StopQuery returns an error but in go-kademlia this is always nil
// found the node we were looking for | ||
d.kad.StopQuery(ctx, qid) | ||
pid := peer.AddrInfo{ | ||
ID: peer.ID(found.ID().(nodeID)), |
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.
It would be cooler if we didn't need to do this type cast here
This looks good. Can we stretch further and implement get providers? |
No description provided.