Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Usage Example #36

Open
ajayrao80 opened this issue Sep 15, 2018 · 11 comments
Open

Usage Example #36

ajayrao80 opened this issue Sep 15, 2018 · 11 comments
Labels
help wanted Seeking public contribution on this issue kind/support A question or request for support status/ready Ready to be worked

Comments

@ajayrao80
Copy link

I couldn't find a clear usage example/documentation. Can anyone help me out?

@vasco-santos vasco-santos added help wanted Seeking public contribution on this issue kind/support A question or request for support status/ready Ready to be worked labels Sep 20, 2018
@vasco-santos
Copy link
Member

vasco-santos commented Sep 20, 2018

Hello @ajayrao80

For now, I can forward you to the js-libp2p code, where this DHT implementation is being used.

js-libp2p/index.js#L109

Let me know if you could understand how to use it.

I would really like to have an example in the README.md, as well as an example with some running code. If you are willing to help after understanding how to use this implementation, I would be really grateful if you create a PR with some examples.

@chris-asl
Copy link

@vasco-santos I might be up for helping with this, since I am currently evaluating whether I can use js-libp2p-kad-dht.

If so, I can write up an example with my usecase.
Would be very grateful if you can give me some pointers on #65 :-)

@vasco-santos
Copy link
Member

Hey @chris-asl

In this issue, I would like to have a simple usage example first. It would be great if you could collaborate!

@chris-asl
Copy link

So, a dummy application that uses the DHT for storing a <key, value> from a node and reading it from another one, would do?

@vasco-santos
Copy link
Member

yes, that would be great!

chris-asl added a commit to chris-asl/js-libp2p-kad-dht that referenced this issue Jan 3, 2019
Add a basic usage example whereby the client code runs on top of each
libp2p DHT node. The idea is that each user has its own deaddrop,
identified by her UserId (on the DHT identifiers namespace), where other
users can leave messages to.

The demo instantiates three application (and thus DHT) nodes. Bootstrap
is handled by having an "always-on" node where others can connect to.
In real world examples, this would not suffice, as a discovery mechanism
needs to be in place (either by using the RandomWalk peer discovery or
by switching any implementations of libp2p/interface-peer-discovery).

Once the nodes are instantiated and connected, thus forming a single
DHT, one deaddrop application (userA) writes a message for userB. Then,
userB reads her messages (after having been informed about the message
through off-channel means).

For this example to make sense, any sent message is encrypted using the
recipient's public key, so that only she can read them, by decrypting
them with her private key.

Resolves libp2p#36.

Signed-off-by: Chris Aslanoglou <[email protected]>
@KrishnaPG
Copy link

Came across this while looking for an usage example. Wondering if any example is available for reference?

@vasco-santos
Copy link
Member

@chris-asl created a PR with an example that you can have a look #69

Meanwhile, we will be switching all the codebase to use async await/iterators and, as the API's will change, we did not get the example merged yet.

@KrishnaPG
Copy link

Thank you @vasco-santos . Does this package work in browser?

@vasco-santos
Copy link
Member

It should work, but it is not highly tested yet. But we are working on integrating this in js-ipfs, including in the browser

@kumavis
Copy link
Contributor

kumavis commented Jun 9, 2019

@KrishnaPG I can happily report it does work in the browser 😸
Though keep in mind the limitations of the transports available in the browser (eg webrtc can have long handshake times that can cause deep dht queries requiring establishing new connections in series take a long time)

@KrishnaPG
Copy link

That is great news. Thank you @kumavis

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Seeking public contribution on this issue kind/support A question or request for support status/ready Ready to be worked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants