diff --git a/pkg/migration/migrate.go b/pkg/migration/migrate.go index 9e8be5ba4f..a2a3d2fddd 100644 --- a/pkg/migration/migrate.go +++ b/pkg/migration/migrate.go @@ -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 @@ -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) +} diff --git a/pkg/repo/fsrepo.go b/pkg/repo/fsrepo.go index 8bc485cc1a..8cd49c86a0 100644 --- a/pkg/repo/fsrepo.go +++ b/pkg/repo/fsrepo.go @@ -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.