Skip to content

Commit

Permalink
keep node config for state preservation
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Dec 12, 2022
1 parent e700f2c commit cb70186
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,21 @@ func (ln *localNetwork) createBlockchainConfigFiles(
// create config, network upgrade and subnet config files
if chainSpec.ChainConfig != nil {
created = true
for nodeName := range ln.nodes {
for nodeName, node := range ln.nodes {
nodeChainConfig := chainSpec.ChainConfig
if conf, ok := chainSpec.PerNodeChainConfig[nodeName]; ok {
// keep contents to write file
nodeChainConfig = conf
// update node config for state preservation
if node.config.ChainConfigFiles == nil {
node.config.ChainConfigFiles = map[string]string{}
}
node.config.ChainConfigFiles[chainAlias] = string(conf)
}
nodeRootDir := getNodeDir(ln.rootDir, nodeName)
chainConfigDir := filepath.Join(nodeRootDir, chainConfigSubDir)
chainConfigPath := filepath.Join(chainConfigDir, chainAlias, configFileName)
if err := createFileAndWrite(chainConfigPath, chainSpec.ChainConfig); err != nil {
if err := createFileAndWrite(chainConfigPath, nodeChainConfig); err != nil {
return false, fmt.Errorf("couldn't write chain config file at %q: %w", chainConfigPath, err)
}
}
Expand Down

0 comments on commit cb70186

Please sign in to comment.