31 lines
656 B
Go
31 lines
656 B
Go
|
package build
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"github.com/filecoin-project/go-lotus/lib/addrutil"
|
||
|
"os"
|
||
|
"strings"
|
||
|
|
||
|
rice "github.com/GeertJohan/go.rice"
|
||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||
|
)
|
||
|
|
||
|
func BuiltinBootstrap() ([]peer.AddrInfo, error) {
|
||
|
var out []peer.AddrInfo
|
||
|
|
||
|
b := rice.MustFindBox("bootstrap")
|
||
|
err := b.Walk("", func(path string, info os.FileInfo, err error) error {
|
||
|
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
|
||
|
}
|