Skip to content

Commit

Permalink
Merge pull request #6183 from filecoin-project/feat/migrate-config
Browse files Browse the repository at this point in the history
feat: migrate boostrap for config
  • Loading branch information
simlecode authored Oct 12, 2023
2 parents a039bec + 04465b8 commit 67ba56d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions pkg/migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var versionMap = []versionInfo{
{version: 9, upgrade: Version9Upgrade},
{version: 10, upgrade: Version10Upgrade},
{version: 11, upgrade: Version11Upgrade},
{version: 12, upgrade: Version12Upgrade},
}

// TryToMigrate used to migrate data(db,config,file,etc) in local repo
Expand Down Expand Up @@ -411,3 +412,27 @@ func Version11Upgrade(repoPath string) (err error) {

return repo.WriteVersion(repoPath, 11)
}

// Version12Upgrade will modify mainnet bootstrap
func Version12Upgrade(repoPath string) (err error) {
var fsrRepo repo.Repo
if fsrRepo, err = repo.OpenFSRepo(repoPath, 11); err != nil {
return
}
cfg := fsrRepo.Config()

switch cfg.NetworkParams.NetworkType {
case types.NetworkMainnet:
cfg.Bootstrap = &networks.Mainnet().Bootstrap
}

if err = fsrRepo.ReplaceConfig(cfg); err != nil {
return
}

if err = fsrRepo.Close(); err != nil {
return
}

return repo.WriteVersion(repoPath, 12)
}
2 changes: 1 addition & 1 deletion pkg/repo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// Version is the version of repo schema that this code understands.
const LatestVersion uint = 11
const LatestVersion uint = 12

const (
// apiFile is the filename containing the filecoin node's api address.
Expand Down

0 comments on commit 67ba56d

Please sign in to comment.