2019-10-09 03:16:35 +00:00
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-05-28 06:52:19 +00:00
|
|
|
"embed"
|
|
|
|
"path"
|
2019-10-09 03:16:35 +00:00
|
|
|
"strings"
|
|
|
|
|
2019-11-22 16:20:56 +00:00
|
|
|
"github.com/filecoin-project/lotus/lib/addrutil"
|
|
|
|
|
2019-10-09 03:16:35 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
)
|
|
|
|
|
2021-05-28 06:52:19 +00:00
|
|
|
//go:embed bootstrap
|
|
|
|
var bootstrapfs embed.FS
|
|
|
|
|
2019-10-09 03:16:35 +00:00
|
|
|
func BuiltinBootstrap() ([]peer.AddrInfo, error) {
|
2020-06-22 18:41:52 +00:00
|
|
|
if DisableBuiltinAssets {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2021-01-06 21:03:29 +00:00
|
|
|
if BootstrappersFile != "" {
|
2021-05-28 06:52:19 +00:00
|
|
|
spi, err := bootstrapfs.ReadFile(path.Join("bootstrap", BootstrappersFile))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if len(spi) == 0 {
|
2021-01-06 21:03:29 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2021-05-28 06:52:19 +00:00
|
|
|
return addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(string(spi)), "\n"))
|
2021-01-05 05:32:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-06 21:03:29 +00:00
|
|
|
return nil, nil
|
2019-10-09 03:16:35 +00:00
|
|
|
}
|