lotus/build/bootstrap.go

35 lines
624 B
Go
Raw Permalink Normal View History

package build
import (
"context"
2021-05-28 06:52:19 +00:00
"embed"
"path"
"strings"
"github.com/libp2p/go-libp2p-core/peer"
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/lotus/lib/addrutil"
)
2021-05-28 06:52:19 +00:00
//go:embed bootstrap
var bootstrapfs embed.FS
func BuiltinBootstrap() ([]peer.AddrInfo, error) {
if DisableBuiltinAssets {
return nil, nil
}
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 {
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
}
return nil, nil
}