Skip to content

Commit

Permalink
add subnet config file to blockchain create
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Nov 11, 2022
1 parent 2dfb55f commit 66f9fcf
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func (ln *localNetwork) createBlockchainConfigFiles(
for i, chainSpec := range chainSpecs {
chainAlias := blockchainTxs[i].ID().String()

// create config and network upgrade files
// create config, network upgrade and subnet config files
if chainSpec.ChainConfig != nil {
created = true
for nodeName := range ln.nodes {
Expand All @@ -774,6 +774,17 @@ func (ln *localNetwork) createBlockchainConfigFiles(
}
}
}
if chainSpec.SubnetConfig != nil {
created = true
for nodeName := range ln.nodes {
nodeRootDir := getNodeDir(ln.rootDir, nodeName)
subnetConfigDir := filepath.Join(nodeRootDir, subnetConfigSubDir)
subnetConfigPath := filepath.Join(subnetConfigDir, *chainSpec.SubnetId+".json")
if err := createFileAndWrite(subnetConfigPath, chainSpec.SubnetConfig); err != nil {
return false, fmt.Errorf("couldn't write chain config file at %q: %w", subnetConfigPath, err)
}
}
}
// update config info for snapshopt/restart purposes
// put into defaults and reset node specifics
if chainSpec.ChainConfig != nil {
Expand All @@ -788,6 +799,12 @@ func (ln *localNetwork) createBlockchainConfigFiles(
delete(ln.nodes[nodeName].config.UpgradeConfigFiles, chainAlias)
}
}
if chainSpec.SubnetConfig != nil {
ln.subnetConfigFiles[*chainSpec.SubnetId] = string(chainSpec.SubnetConfig)
for nodeName := range ln.nodes {
delete(ln.nodes[nodeName].config.SubnetConfigFiles, *chainSpec.SubnetId)
}
}
}
return created, nil
}
Expand Down

0 comments on commit 66f9fcf

Please sign in to comment.