This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
dht functionality #1857
Labels
exp/expert
Having worked on the specific codebase is important
kind/bug
A bug in existing code (including security flaws)
P1
High: Likely tackled by core team if no one steps up
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? |
alanshaw
added
kind/bug
A bug in existing code (including security flaws)
exp/expert
Having worked on the specific codebase is important
status/ready
Ready to be worked
P1
High: Likely tackled by core team if no one steps up
labels
Feb 6, 2019
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
exp/expert
Having worked on the specific codebase is important
kind/bug
A bug in existing code (including security flaws)
P1
High: Likely tackled by core team if no one steps up
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 failed
from 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: