Replies: 2 comments 6 replies
-
How did you configure your other nodes? Does your bootstrap node have a static IP address/port? I ask because I see a bunch of NAT options and putting a bootstrap node behind a NAT generally doesn't work well. |
Beta Was this translation helpful? Give feedback.
6 replies
-
When starting a bootstrap, don’t forget to initiate it. package main
import (
"context"
"github.com/libp2p/go-libp2p"
dht "github.com/libp2p/go-libp2p-kad-dht"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/routing"
)
type Config struct {
PrivateKey crypto.PrivKey
Bootstrap bool
}
func CreateNode(ctx context.Context, cfg *Config) (h host.Host, ddht *dht.IpfsDHT, err error) {
options := []libp2p.Option{
libp2p.EnableAutoNATv2(),
libp2p.NATPortMap(),
libp2p.EnableNATService(),
libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) {
ddht, err = dht.New(ctx, h)
if err != nil {
return nil, err
}
return ddht, nil
}),
libp2p.ForceReachabilityPublic(),
libp2p.FallbackDefaults,
}
if cfg.PrivateKey != nil {
options = append(options, libp2p.Identity(cfg.PrivateKey))
}
h, err = libp2p.New(options...)
if err != nil {
return nil, ddht,err
}
if cfg.Bootstrap {
if err := ddht.Bootstrap(ctx); err != nil {
return nil,ddht, err
}
}
return h, ddht,err
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to build my own dht boostrap node, but when I use the libp2p configuration above I find that other nodes can't connect to it.
Beta Was this translation helpful? Give feedback.
All reactions