From 66f9fcf4772e5777702e6c75f98367dc69528e91 Mon Sep 17 00:00:00 2001 From: Felipe Madero Date: Fri, 11 Nov 2022 18:25:21 -0300 Subject: [PATCH] add subnet config file to blockchain create --- local/blockchain.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/local/blockchain.go b/local/blockchain.go index f1984e02..4a26d3b9 100644 --- a/local/blockchain.go +++ b/local/blockchain.go @@ -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 { @@ -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 { @@ -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 }