2019-10-09 03:16:35 +00:00
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
2019-11-22 16:20:56 +00:00
|
|
|
"github.com/filecoin-project/lotus/lib/addrutil"
|
2019-12-05 05:14:19 +00:00
|
|
|
"golang.org/x/xerrors"
|
2019-11-22 16:20:56 +00:00
|
|
|
|
2019-10-09 03:16:35 +00:00
|
|
|
rice "github.com/GeertJohan/go.rice"
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BuiltinBootstrap() ([]peer.AddrInfo, error) {
|
2020-06-22 18:41:52 +00:00
|
|
|
if DisableBuiltinAssets {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2019-10-09 03:16:35 +00:00
|
|
|
var out []peer.AddrInfo
|
|
|
|
|
|
|
|
b := rice.MustFindBox("bootstrap")
|
|
|
|
err := b.Walk("", func(path string, info os.FileInfo, err error) error {
|
2019-12-05 05:14:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to walk box: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-10-09 03:16:35 +00:00
|
|
|
if !strings.HasSuffix(path, ".pi") {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
spi := b.MustString(path)
|
|
|
|
if spi == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
pi, err := addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(spi), "\n"))
|
|
|
|
out = append(out, pi...)
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
return out, err
|
|
|
|
}
|
2020-06-08 09:31:33 +00:00
|
|
|
|
|
|
|
func DrandBootstrap() ([]peer.AddrInfo, error) {
|
|
|
|
addrs := []string{
|
2020-07-14 19:16:06 +00:00
|
|
|
"/dnsaddr/dev1.drand.sh/",
|
|
|
|
"/dnsaddr/dev2.drand.sh/",
|
2020-06-08 09:31:33 +00:00
|
|
|
}
|
|
|
|
return addrutil.ParseAddresses(context.TODO(), addrs)
|
|
|
|
}
|