You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In line 32 they run discoverPeers(). This function first runs initDHT(). I dont understand what happens in initDHT: I know that there is a list of known bootstrap nodes that somebody runs. So if a new node wants to join the libp2p network, then the node first contacts/connects to the default bootstrap nodes. But what do they reply? Do the bootstrap nodes reply with a list of all nodes that contacted them in the past x hours? Is the general idea that the new node now at least knows a few other random libp2p nodes that he can contact? But then i dont understand what "kademlia" is even used for here. In my head you go to a bootstrap node and tell them who you are, they will remember it and give you a list of nodes that previously were there. thats sounds very simple, what does a distributed hash table even do here? does kademlia here mean that every new node becomes a bootstrap node? but how can that possible work, my nodes are all behind a NAT so i dont think they would be able to act as boostrap node.
apparently after running initDHT() the new node is connected to bootstrap nodes. so now in discoverPeers() lines 81 and 82 it will do "routing discovery" with the user-provided flag. now this is another thing i dont understand: the linked example is called basic-chat-with-rendezvous. Is this the part where rendezvous comes into play? Is the user provided flag the "rendezvous" string? So maybe a bootstrap node will not reply with every node that ever visited it, but instead only with the list of nodes that declared the same rendezvous string ? okay, but this cant be the case because we never transmitted the user-provided flag to the bootstrap nodes..
Now in the rest of this function it seems as if the node tries to connect to a single node that FindPeers() returns. What is FindPeers even doing? Is this already the pubsub part of the application or are we still only using kademlia dht + rendezvous so far? Is it a coincidence in the linked example that the pubsub topic and the rendezview string are the exact same thing (line 38 vs line 82)? I struggle to understand this. Especially when i try to extend this example with multiple topics, then what do i put as rendezvous string?
okay "Peer discovery complete". so it means we have direct communication to one node who specified the same rendezvous message? Now it seems that the pubsub stuff is starting: gossipsub is used to "join" the user-provided topic. So now it starts two functions: one for receiving incoming topic messages and one for allowing the user to "send to the topic" [i have read this online]. but what does it even mean to send to a topic? its just an abstract concept and not someone you can contact. so does it mean i check the topics of the node we previously directly connected to, check its subscribed topics and if it matches directly send it to him? okay i understand that this is trivial when i start this program twice and there are only two nodes. but what if there are 1000 subscribers to a topic. would i need to change the example so that i have a direct communcation to 1000 nodes? or would i still only directly connect to 1 of these 1000 nodes and hope that this node will spread my message to the others? what if he doesnt... but if i send the message to everyone directly 1000 times, then whats the point of topics?
so in step 2 we made a DIRECT connection to every node that is subscribed to a topic we are interested in? so technically, a "topic" actually just means: go through every direct connection you have, check the topics your connection partners are interested in, and if they are interested in the topic you currently want to send a message to then send it to them? or am i wrong and "sending a message to a topic" means you send your message to x other topic subscribers and they spread your message to everyone else who has subbed to the topic (the gossiping part)? but then why did the example directly connect to every single node that is subbed to the same topic? i thought i just need to send it to one node and they spread it for me
my goal is to extend the example to that instead of only one topic you start the program with many topics. you use goroutines to listen to all these topics at the same time and you start one function for sending out to topics and how you send is : format, so that this one function is able to send to every topic.
should i maybe completely ditch rendezvous? is that possible? some online sources sound as if using rendezvous were not necessary ('kademlia dht is FULLY decentralized') but then other sources make it seem as if it were ('bootstrap nodes are the ONLY centralized necessity'). Then the wikipedia article of bootrapping node implies that its the same thing as rendezvous, then other sources tell me that it does not have to be the same thing. i struggle to learn anything when i keep encountering conflicting information.
sorry for this long question. i really want to understand what is going on here to find out what i need to do to extend the linked example with more functionality
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
hello, i want to build sth on top of the given example (https://github.com/libp2p/go-libp2p/blob/master/examples/pubsub/basic-chat-with-rendezvous/main.go) and i have problems understanding certain things. so here is a list of things that are not clear to me:
In line 32 they run discoverPeers(). This function first runs initDHT(). I dont understand what happens in initDHT: I know that there is a list of known bootstrap nodes that somebody runs. So if a new node wants to join the libp2p network, then the node first contacts/connects to the default bootstrap nodes. But what do they reply? Do the bootstrap nodes reply with a list of all nodes that contacted them in the past x hours? Is the general idea that the new node now at least knows a few other random libp2p nodes that he can contact? But then i dont understand what "kademlia" is even used for here. In my head you go to a bootstrap node and tell them who you are, they will remember it and give you a list of nodes that previously were there. thats sounds very simple, what does a distributed hash table even do here? does kademlia here mean that every new node becomes a bootstrap node? but how can that possible work, my nodes are all behind a NAT so i dont think they would be able to act as boostrap node.
apparently after running initDHT() the new node is connected to bootstrap nodes. so now in discoverPeers() lines 81 and 82 it will do "routing discovery" with the user-provided flag. now this is another thing i dont understand: the linked example is called basic-chat-with-rendezvous. Is this the part where rendezvous comes into play? Is the user provided flag the "rendezvous" string? So maybe a bootstrap node will not reply with every node that ever visited it, but instead only with the list of nodes that declared the same rendezvous string ? okay, but this cant be the case because we never transmitted the user-provided flag to the bootstrap nodes..
Now in the rest of this function it seems as if the node tries to connect to a single node that FindPeers() returns. What is FindPeers even doing? Is this already the pubsub part of the application or are we still only using kademlia dht + rendezvous so far? Is it a coincidence in the linked example that the pubsub topic and the rendezview string are the exact same thing (line 38 vs line 82)? I struggle to understand this. Especially when i try to extend this example with multiple topics, then what do i put as rendezvous string?
okay "Peer discovery complete". so it means we have direct communication to one node who specified the same rendezvous message? Now it seems that the pubsub stuff is starting: gossipsub is used to "join" the user-provided topic. So now it starts two functions: one for receiving incoming topic messages and one for allowing the user to "send to the topic" [i have read this online]. but what does it even mean to send to a topic? its just an abstract concept and not someone you can contact. so does it mean i check the topics of the node we previously directly connected to, check its subscribed topics and if it matches directly send it to him? okay i understand that this is trivial when i start this program twice and there are only two nodes. but what if there are 1000 subscribers to a topic. would i need to change the example so that i have a direct communcation to 1000 nodes? or would i still only directly connect to 1 of these 1000 nodes and hope that this node will spread my message to the others? what if he doesnt... but if i send the message to everyone directly 1000 times, then whats the point of topics?
so in step 2 we made a DIRECT connection to every node that is subscribed to a topic we are interested in? so technically, a "topic" actually just means: go through every direct connection you have, check the topics your connection partners are interested in, and if they are interested in the topic you currently want to send a message to then send it to them? or am i wrong and "sending a message to a topic" means you send your message to x other topic subscribers and they spread your message to everyone else who has subbed to the topic (the gossiping part)? but then why did the example directly connect to every single node that is subbed to the same topic? i thought i just need to send it to one node and they spread it for me
my goal is to extend the example to that instead of only one topic you start the program with many topics. you use goroutines to listen to all these topics at the same time and you start one function for sending out to topics and how you send is : format, so that this one function is able to send to every topic.
should i maybe completely ditch rendezvous? is that possible? some online sources sound as if using rendezvous were not necessary ('kademlia dht is FULLY decentralized') but then other sources make it seem as if it were ('bootstrap nodes are the ONLY centralized necessity'). Then the wikipedia article of bootrapping node implies that its the same thing as rendezvous, then other sources tell me that it does not have to be the same thing. i struggle to learn anything when i keep encountering conflicting information.
sorry for this long question. i really want to understand what is going on here to find out what i need to do to extend the linked example with more functionality
Beta Was this translation helpful? Give feedback.
All reactions