OSDN Git Service

prod config for mov (#524)
[bytom/vapor.git] / config / toml.go
1 package config
2
3 import (
4         "path"
5
6         cmn "github.com/tendermint/tmlibs/common"
7 )
8
9 /****** these are for production settings ***********/
10 func EnsureRoot(rootDir string, network string) {
11         cmn.EnsureDir(rootDir, 0700)
12         cmn.EnsureDir(rootDir+"/data", 0700)
13
14         configFilePath := path.Join(rootDir, "config.toml")
15
16         // Write default config file if missing.
17         if !cmn.FileExists(configFilePath) {
18                 cmn.MustWriteFile(configFilePath, []byte(selectNetwork(network)), 0644)
19         }
20 }
21
22 var defaultConfigTmpl = `# This is a TOML config file.
23 # For more information, see https://github.com/toml-lang/toml
24 fast_sync = true
25 db_backend = "leveldb"
26 api_addr = "0.0.0.0:9889"
27 moniker = ""
28 `
29
30 var mainNetConfigTmpl = `chain_id = "mainnet"
31 [p2p]
32 laddr = "tcp://0.0.0.0:56656"
33 seeds = "47.103.79.68:56656,47.103.13.86:56656,47.102.193.119:56656,47.103.17.22:56656"
34 [cross_chain]
35 asset_whitelist = "184e1cc4ee4845023888810a79eed7a42c02c544cf2c61ceac05e176d575bd46,78de44ffa1bce37b757c9eae8925b5f199dc4621b412ef0f3f46168865284a93"
36 `
37
38 var testNetConfigTmpl = `chain_id = "testnet"
39 [p2p]
40 laddr = "tcp://0.0.0.0:56657"
41 seeds = "52.82.7.233:56657,52.82.109.252:56657,52.82.29.30:56657"
42 [cross_chain]
43 asset_whitelist = ""
44 `
45
46 var soloNetConfigTmpl = `chain_id = "solonet"
47 [p2p]
48 laddr = "tcp://0.0.0.0:56658"
49 seeds = ""
50 [cross_chain]
51 asset_whitelist = ""
52 `
53
54 // Select network seeds to merge a new string.
55 func selectNetwork(network string) string {
56         switch network {
57         case "mainnet":
58                 return defaultConfigTmpl + mainNetConfigTmpl
59         case "testnet":
60                 return defaultConfigTmpl + testNetConfigTmpl
61         default:
62                 return defaultConfigTmpl + soloNetConfigTmpl
63         }
64 }