Skip to content

Commit

Permalink
feat: p2p: allow overriding bootstrap nodes with environmemnt variable (
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored and ribasushi committed Aug 20, 2024
1 parent c91f3de commit 5fe11c6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions build/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package build
import (
"context"
"embed"
"os"
"path"
"strings"

Expand All @@ -12,13 +13,21 @@ import (
"github.com/filecoin-project/lotus/lib/addrutil"
)

const (
BootstrappersOverrideEnvVarKey = "LOTUS_P2P_BOOTSTRAPPERS"
)

//go:embed bootstrap
var bootstrapfs embed.FS

func BuiltinBootstrap() ([]peer.AddrInfo, error) {
if DisableBuiltinAssets {
return nil, nil
}
if bootstrappers, found := os.LookupEnv(BootstrappersOverrideEnvVarKey); found {
log.Infof("Using bootstrap nodes overridden by environment variable %s", BootstrappersOverrideEnvVarKey)
return addrutil.ParseAddresses(context.TODO(), strings.Split(strings.TrimSpace(bootstrappers), ","))
}
if buildconstants.BootstrappersFile != "" {
spi, err := bootstrapfs.ReadFile(path.Join("bootstrap", buildconstants.BootstrappersFile))
if err != nil {
Expand Down

0 comments on commit 5fe11c6

Please sign in to comment.