Simplify network type handling

pull/1300/head
Eugene Kim 5 years ago
parent d6925abf1a
commit 02c68947ef
  1. 13
      cmd/harmony/main.go
  2. 6
      internal/shardchain/shardchains.go
  3. 6
      node/node_genesis.go

@ -234,15 +234,10 @@ func createGlobalConfig() *nodeconfig.ConfigType {
}
// Set network type
switch *networkType {
case nodeconfig.Mainnet:
nodeConfig.SetNetworkType(nodeconfig.Mainnet)
case nodeconfig.Testnet:
nodeConfig.SetNetworkType(nodeconfig.Testnet)
case nodeconfig.Localnet:
nodeConfig.SetNetworkType(nodeconfig.Localnet)
case nodeconfig.Devnet:
nodeConfig.SetNetworkType(nodeconfig.Devnet)
netType := nodeconfig.NetworkType(*networkType)
switch netType {
case nodeconfig.Mainnet, nodeconfig.Testnet, nodeconfig.Localnet, nodeconfig.Devnet:
nodeConfig.SetNetworkType(netType)
default:
panic(fmt.Sprintf("invalid network type: %s", *networkType))
}

@ -97,11 +97,7 @@ func (sc *CollectionImpl) ShardChain(shardID uint32, networkType nodeconfig.Netw
switch networkType {
case nodeconfig.Mainnet:
chainConfig = *params.MainnetChainConfig
case nodeconfig.Testnet:
fallthrough
case nodeconfig.Localnet:
fallthrough
case nodeconfig.Devnet:
default: // all other network types share testnet config
chainConfig = *params.TestnetChainConfig
}

@ -74,11 +74,7 @@ func (node *Node) SetupGenesisBlock(db ethdb.Database, shardID uint32, myShardSt
genesisFunds = genesisFunds.Mul(genesisFunds, big.NewInt(denominations.One))
genesisAlloc[foundationAddress] = core.GenesisAccount{Balance: genesisFunds}
}
case nodeconfig.Testnet:
fallthrough
case nodeconfig.Localnet:
fallthrough
case nodeconfig.Devnet:
default: // all other types share testnet config
chainConfig = *params.TestnetChainConfig
// Tests account for txgen to use
node.AddTestingAddresses(genesisAlloc, TestAccountNumber)

Loading…
Cancel
Save