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/filecoin-project/lotus/lib/addrutil"
"github.com/libp2p/go-libp2p-core/peer"
)
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
}