Hi, community,
I’m new to the world of P2P and Kad so I have a basic question. So I have piece of code like this that creates a host and a DHT:
node, err := libp2p.New(ctx,
libp2p.ListenAddrStrings(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", port)),
libp2p.Identity(prvKey))
// create a kadDHT
kadDHT, err := dht.New(ctx, node,
dht.Validator(utils.NullValidator{}),
dht.ProtocolPrefix("/myapp"))
Then I connect DHT hosts to each other (via node.Connect
) , but then I can’t figure out make the DHT work. I tried PutValue
and get an error saying “no peers in the routing table.” It seems like although they are connected via TCP they did not appear in each others routing table.
The doc does say:
New creates a new DHT with the specified host and options. Please note that being connected to a DHT peer does not necessarily imply that it’s also in the DHT Routing Table. If the Routing Table has more than “minRTRefreshThreshold” peers, we consider a peer as a Routing Table candidate ONLY when we successfully get a query response from it OR if it send us a query.
By default minRTRefreshThreshold=4
so I don’t think this warning applies to empty routing table. Did I miss anything?