Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

dennis-tra
Copy link
Contributor

No description provided.

@dennis-tra dennis-tra requested a review from iand August 14, 2023 14:28
Comment on lines +40 to +42
qSubs map[query.QueryID]chan<- kad.Response[key.Key256, ma.Multiaddr]
qSubsLk sync.RWMutex
qSubCnt uint64
Copy link
Contributor Author

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

Copy link

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)
Copy link
Contributor Author

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)),
Copy link
Contributor Author

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

@iand
Copy link

iand commented Aug 14, 2023

This looks good. Can we stretch further and implement get providers?

@dennis-tra dennis-tra closed this Sep 8, 2023
@dennis-tra dennis-tra deleted the go-kademlia-integration branch September 8, 2023 08:07
@dennis-tra dennis-tra added the v2 All issues related to the v2 rewrite label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 All issues related to the v2 rewrite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants