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 Jul 26, 2024
1 parent a6fd2eb commit 9c9bb95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- https://github.com/filecoin-project/lotus/pull/12285 Set up OpenTelemetry metrics reporting to prometheus
- https://github.com/filecoin-project/lotus/pull/12279 Upgrade to go-f3 v0.0.5
- https://github.com/filecoin-project/lotus/pull/12295 Upgrade to go-f3 v0.0.6
- https://github.com/filecoin-project/lotus/pull/12292: feat: p2p: allow overriding bootstrap nodes with environmemnt variable

## New features

Expand Down
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 9c9bb95

Please sign in to comment.