Use the DHT bootstrap peer list
This commit is contained in:
parent
69f030e66b
commit
bf8a925ce9
31
bootstrap.go
31
bootstrap.go
|
@ -6,45 +6,24 @@ import (
|
|||
"math/rand"
|
||||
"time"
|
||||
|
||||
dht "github.com/libp2p/go-libp2p-kad-dht"
|
||||
inet "github.com/libp2p/go-libp2p-net"
|
||||
pstore "github.com/libp2p/go-libp2p-peerstore"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
var BootstrapPeers = []string{
|
||||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
||||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
|
||||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
|
||||
"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
|
||||
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", // mars.i.ipfs.io
|
||||
"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io
|
||||
"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io
|
||||
"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io
|
||||
"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io
|
||||
"/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", // pluto.i.ipfs.io
|
||||
"/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", // saturn.i.ipfs.io
|
||||
"/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", // venus.i.ipfs.io
|
||||
"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", // earth.i.ipfs.io
|
||||
}
|
||||
var BootstrapPeers = dht.DefaultBootstrapPeers
|
||||
|
||||
const BootstrapConnections = 4
|
||||
|
||||
func bootstrapPeerInfo() ([]*pstore.PeerInfo, error) {
|
||||
pis := make([]*pstore.PeerInfo, len(BootstrapPeers))
|
||||
for x, p := range BootstrapPeers {
|
||||
a, err := ma.NewMultiaddr(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pis []*pstore.PeerInfo
|
||||
for _, a := range BootstrapPeers {
|
||||
pi, err := pstore.InfoFromP2pAddr(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pis[x] = pi
|
||||
pis = append(pis, pi)
|
||||
}
|
||||
|
||||
return pis, nil
|
||||
}
|
||||
|
||||
|
|
10
p2pd/main.go
10
p2pd/main.go
|
@ -13,7 +13,7 @@ import (
|
|||
p2pd "github.com/libp2p/go-libp2p-daemon"
|
||||
ps "github.com/libp2p/go-libp2p-pubsub"
|
||||
quic "github.com/libp2p/go-libp2p-quic-transport"
|
||||
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
|
||||
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
|
||||
multiaddr "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
|
@ -128,7 +128,13 @@ func main() {
|
|||
}
|
||||
|
||||
if *bootstrapPeers != "" {
|
||||
p2pd.BootstrapPeers = strings.Split(*bootstrapPeers, ",")
|
||||
for _, s := range strings.Split(*bootstrapPeers, ",") {
|
||||
ma, err := multiaddr.NewMultiaddr(s)
|
||||
if err != nil {
|
||||
log.Fatalf("error parsing bootstrap peer %q: %v", s, err)
|
||||
}
|
||||
p2pd.BootstrapPeers = append(p2pd.BootstrapPeers, ma)
|
||||
}
|
||||
}
|
||||
|
||||
if *bootstrap {
|
||||
|
|
Loading…
Reference in New Issue