Open sekomer opened 3 months ago
Hi, This example uses the default guide node, and the default bootstrap node seems to be unable to connect, which requires self built bootstrap nodes. This is my example code:
prvKey, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader)
if err != nil {
log.Println(err)
return
}
relay1, err := libp2p.New(libp2p.Identity(prvKey), libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/9876", "/ip4/0.0.0.0/udp/9876/quic-v1"))
if err != nil {
log.Printf("Failed to create relay1: %v", err)
return
}
_, err = relay.New(relay1)
if err != nil {
log.Printf("Failed to instantiate the relay: %v", err)
return
}
_, err = dht.New(context.Background(), relay1, dht.Mode(dht.ModeServer)) //
if err != nil {
log.Printf("Failed to create DHT: %v", err)
return
}
fmt.Printf("[*] Your Bootstrap ID Is: /ip4/%s/tcp/%v/p2p/%s\n", "0.0.0.0", 9876, relay1.ID().String())
You can specify the bootstrap node by specifying the -peer
parameter.
But I found that this example is not have holepunching, even if the EnableHolePunching is added, it will not take effect.
That's what I've been exploring, I'm not sure at the moment why the hole punching isn't working.
https://github.com/libp2p/go-libp2p/issues/2878
https://github.com/libp2p/go-libp2p/issues/2761#issuecomment-2235856645
https://github.com/libp2p/go-libp2p/issues/2761#issuecomment-2235971016
@iGwkang thanks buddy,
I am trying to build a blockchain, therefore each node should be behaving same, when someone wants to join the p2p network, I want each of the nodes to act as a bootstrap node, is this possible with this example and your solution after initial start of the network, and some number of peers are active?
hi, im trying to build a toy blockchain to learn fundamentals. I want to use libp2p for communicating nodes. (I tried couple of things, correct me if I tell anything wrong below)
I tried
pub/sub
example, but that was communicating over a relay node, peers doesn't directly communicating each other but messages coming from a single bootstrapper node.Then I tried
chat with mdns
example, I could do the things I want to do using it, but then I realized I cannot use that globally, its only for LAN network.Then I switched to
chat with rendezvous
example, it seems like it can solve my problem, but I cannot run the nodes, im getting the following error, immediately after starting the first node.My question is, for my case, which examples should I rely on for communicating the nodes in my blockchain? And if its the
chat with rendezvous
example, how I can fix the error below :Dthanks in advance