From cb167f9180866e53a48c723cf10e7cc7d5753706 Mon Sep 17 00:00:00 2001 From: AnilChinchawale Date: Wed, 31 Oct 2018 10:42:04 +0530 Subject: [PATCH] move config bootnode to xdc toml file --- cmd/XDC/config.go | 46 ++++++++++++++++++++++++++++++--------- cmd/XDC/main.go | 7 ++---- cmd/XDC/testdata/XDC.toml | 24 ++++++++++++++++++-- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/cmd/XDC/config.go b/cmd/XDC/config.go index 81c412f7f3..9eb36dc3bd 100644 --- a/cmd/XDC/config.go +++ b/cmd/XDC/config.go @@ -79,14 +79,23 @@ type account struct { Unlocks []string `toml:"unlocks"` Passwords []string `toml:"passwords"` } -type XDC Config struct { - Eth eth.Config `toml:"eth"` - Shh whisper.Config `toml:"ssh"` - Node node.Config `toml:"node"` - Ethstats ethstatsConfig `toml:"ethstats"` - Dashboard dashboard.Config `toml:"dashboard"` - Account account `toml:"account"` - MineEnable bool `toml:"mine"` + +type Bootnodes struct { + Mainnet []string `toml:"main"` + Testnet []string `toml:"test"` + Rinkeby []string `toml:"rinkeby"` + DiscoveryV5 []string `toml:"discoveryv5"` +} + +type XDCConfig struct { + Eth eth.Config `toml:"eth"` + Shh whisper.Config `toml:"ssh"` + Node node.Config `toml:"node"` + Ethstats ethstatsConfig `toml:"ethstats"` + Dashboard dashboard.Config `toml:"dashboard"` + Account account `toml:"account"` + StakeEnable bool `toml:"stake"` + Bootnodes Bootnodes `toml:"bootnodes"` } func loadConfig(file string, cfg *XDCConfig) error { @@ -134,14 +143,18 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) { if trimmed := strings.TrimSpace(env); trimmed != "" { value := os.Getenv(trimmed) for _, info := range strings.Split(value, ",") { - trimmed2 := strings.TrimSpace(info) - if (trimmed2 != "") { + if trimmed2 := strings.TrimSpace(info); trimmed2 != "" { passwords = append(passwords, trimmed2) } } } } cfg.Account.Passwords = passwords + //Apply Bootnodes + applyValues(cfg.Bootnodes.Mainnet, ¶ms.MainnetBootnodes) + applyValues(cfg.Bootnodes.Testnet, ¶ms.TestnetBootnodes) + applyValues(cfg.Bootnodes.Rinkeby, ¶ms.RinkebyBootnodes) + applyValues(cfg.Bootnodes.DiscoveryV5, ¶ms.DiscoveryV5Bootnodes) // Apply flags. utils.SetNodeConfig(ctx, &cfg.Node) @@ -160,6 +173,19 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) { return stack, cfg } +func applyValues(values []string, params *[]string) { + data := []string{} + for _, value := range values { + if trimmed := strings.TrimSpace(value); trimmed != "" { + data = append(data, trimmed) + } + } + if len(data) > 0 { + *params = data + } + +} + // enableWhisper returns true in case one of the whisper flags is set. func enableWhisper(ctx *cli.Context) bool { for _, flag := range whisperFlags { diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index 555dd4e9d0..b20072782c 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -229,13 +229,11 @@ func startNode(ctx *cli.Context, stack *node.Node,cfg XDCConfig) { // Unlock any account specifically requested ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - //passwords := utils.MakePasswordList(ctx) - //unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") if(ctx.GlobalIsSet(utils.UnlockedAccountFlag.Name)) { cfg.Account.Unlocks=strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") } - if(ctx.GlobalIsSet(utils.PasswordFileFlag.Name)) { + if(ctx.GlobalIsSet(utils.PasswordFileFlag.Name)) { cfg.Account.Passwords=utils.MakePasswordList(ctx) } @@ -286,8 +284,7 @@ func startNode(ctx *cli.Context, stack *node.Node,cfg XDCConfig) { } }() // Start auxiliary services if enabled - //if ctx.GlobalBool(utils.StakingEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) { - if cfg.MineEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { + if cfg.StakeEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { // Mining only makes sense if a full Ethereum node is running if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { utils.Fatalf("Light clients do not support staking") diff --git a/cmd/XDC/testdata/XDC.toml b/cmd/XDC/testdata/XDC.toml index e036cb5c2f..45b0230a16 100644 --- a/cmd/XDC/testdata/XDC.toml +++ b/cmd/XDC/testdata/XDC.toml @@ -1,4 +1,4 @@ -mine = true # flag --mine ( true : enable miner , false : disable ) +stake = true # flag --stake ( true : enable staker , false : disable ) [eth] NetworkId = 1515 # flag --networkid SyncMode = "full" # flag --syncmode @@ -20,4 +20,24 @@ bootnodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559 [dashboard] [account] unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock -passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 \ No newline at end of file +passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 + + +[bootnodes] +main =["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303", + "enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303", + "enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303", + "enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303", + "enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303", + "enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"] +test =["enode://30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606@52.176.7.10:30303", + "enode://865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c@52.176.100.77:30303", + "enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303", + "enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303" ] +rinkeby =["enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303", + "enode://343149e4feefa15d882d9fe4ac7d88f885bd05ebb735e547f12e12080a9fa07c8014ca6fd7f373123488102fe5e34111f8509cf0b7de3f5b44339c9f25e87cb8@52.3.158.184:30303", + "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303"] +discoveryv5 =["enode://06051a5573c81934c9554ef2898eb13b33a34b94cf36b202b69fde139ca17a85051979867720d4bdae4323d4943ddf9aeeb6643633aa656e0be843659795007a@35.177.226.168:30303", + "enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30304", + "enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30306", + "enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30307"] \ No newline at end of file