libp2p / go-libp2p

libp2p implementation in Go
MIT License
5.9k stars 1.04k forks source link

Query: Where is the bootstrap package in the latest version? #2802

Open paulwizviz opened 2 months ago

paulwizviz commented 2 months ago

I am new to the library. I was told there is a bootstrap package to support bootstrap-based discovery.

sukunrt commented 2 months ago

I think you are looking for go-libp2p-kad-dht Here is the bootstrap peers option for it: https://github.com/libp2p/go-libp2p-kad-dht/blob/master/dht_options.go#L275

For mdns based discovery look at https://pkg.go.dev/github.com/libp2p/go-libp2p/p2p/discovery/mdns

paulwizviz commented 2 months ago

I think you are looking for go-libp2p-kad-dht Here is the bootstrap peers option for it: https://github.com/libp2p/go-libp2p-kad-dht/blob/master/dht_options.go#L275

For mdns based discovery look at https://pkg.go.dev/github.com/libp2p/go-libp2p/p2p/discovery/mdns

I think you are looking for go-libp2p-kad-dht Here is the bootstrap peers option for it: https://github.com/libp2p/go-libp2p-kad-dht/blob/master/dht_options.go#L275

For mdns based discovery look at https://pkg.go.dev/github.com/libp2p/go-libp2p/p2p/discovery/mdns

I was looking at an example code that references this "github.com/libp2p/go-libp2p/p2p/discovery/routing". But I can't find it in that latest version.

This is what I was trying to do.

    bootstrapConfig := bootstrap.BootstrapConfigWithPeers([]peer.AddrInfo{*bootstrapPeer})
    bootstrapService, err := bootstrap.NewBootstrapService(ctx, h, bootstrapConfig)
    if err != nil {
        log.Fatal(err)
    }

    // Start the bootstrap service
    if err := bootstrapService.Start(); err != nil {
        log.Fatal(err)
    }

However, I could not find that package in the go-libp2p module. I would like to test a scenario where peers could be found on a WAN or the Internet. I understand libp2p DHT can achieve this. Is that correct?