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
dht functionality #1857
Comments
|
Is the peer you’re trying to get the file from listening on an address that your browser node can connect to? |
|
@alanshaw I'm already connected as shown by node.swarm.peers(). |
|
@vasco-santos can we resolve this before #856 is merged? |
|
I will have a look in this |
|
Hello @Gaillard I did a small test: const node = new IPFS({
repo: String(Math.random() + Date.now()),
libp2p: {
config: {
dht: {
enabled: true
}
}
}
})
node.once('ready', async () => {
let peers
peers = await node.swarm.peers() // empty peers (still connecting)
setTimeout(async () => {
peers = await node.swarm.peers() // several peers (connected now)
if (peers.length) {
const b58peerId = peers[0].peer._idB58String
const peerId = await node.dht.findPeer(b58peerId)
console.log('peerId', peerId)
}
}, 5000)
})Basically, when the node is ready, it starts connecting to the peers. That way, if you immediatly try to find the peer and you are not connected with it yet, you will not be able to find it. In my example, just a small test with a timeout, I wait a few seconds and then try to find a peer that is connected, and it worked fine in a React app. Let me know if this answer helped you. If not, please provide me an example failing ready to run. |
yonderblue commentedJan 31, 2019
•
edited
feat/dht-part-ii branch (b0acc71)
mac/linux
dht
I just used browserify directly on a little example while having the feat/dhs-part-ii branch checked out.
So now my index.js looks like
However I always get
Error: Peer lookup failedfrom that last line.Also even trying to do a
node.get('THE_PEER_FILE_HASH')just hangs, even though that peers is in thenode.swarm.peers()(only one since its the bootstrap).If I take out the swarm key and connect to public network, the findPeer doesn't fail but always returns nothing, same with findProvs etc.
The text was updated successfully, but these errors were encountered: