From b0e95fcc58f873d00227685594b67def1358b42c Mon Sep 17 00:00:00 2001 From: parmarrushabh Date: Wed, 31 Oct 2018 11:14:32 +0530 Subject: [PATCH] fix reduce change code --- cmd/XDC/config.go | 26 +++++++++++++------------- cmd/XDC/testdata/XDC.toml | 29 ----------------------------- cmd/XDC/testdata/config.toml | 28 ++++++++++++++++++++++++++++ consensus/ethash/ethash.go | 12 ++++++------ dashboard/config.go | 6 +++--- eth/config.go | 10 ++++------ node/config.go | 18 +++++++++--------- p2p/server.go | 6 +++--- 8 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 cmd/XDC/testdata/XDC.toml create mode 100644 cmd/XDC/testdata/config.toml diff --git a/cmd/XDC/config.go b/cmd/XDC/config.go index 4fc0565fce..2f609e1587 100644 --- a/cmd/XDC/config.go +++ b/cmd/XDC/config.go @@ -72,28 +72,28 @@ var tomlSettings = toml.Config{ } type ethstatsConfig struct { - URL string `toml:"url"` + URL string `toml:",omitempty"` } type account struct { - Unlocks []string `toml:"unlocks"` - Passwords []string `toml:"passwords"` + Unlocks []string + Passwords []string } type Bootnodes struct { - Mainnet []string `toml:"main"` - Testnet []string `toml:"test"` + Mainnet []string + Testnet []string } 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"` + Eth eth.Config + Shh whisper.Config + Node node.Config + Ethstats ethstatsConfig + Dashboard dashboard.Config + Account account + StakeEnable bool + Bootnodes Bootnodes } func loadConfig(file string, cfg *XDCConfig) error { diff --git a/cmd/XDC/testdata/XDC.toml b/cmd/XDC/testdata/XDC.toml deleted file mode 100644 index a88030669c..0000000000 --- a/cmd/XDC/testdata/XDC.toml +++ /dev/null @@ -1,29 +0,0 @@ - -stake = true # flag --stake ( true : enable staker , false : disable ) -[eth] -NetworkId = 1515 # flag --networkid -SyncMode = "full" # flag --syncmode -GasPrice = 1 # flag --gasprice - -[ssh] - -[node] -datadir = "node1/" # flag --datadir -http_host = "localhost" # flag --rpcaddr -http_port = 8501 # flag --rpcport -http_modules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi -[node.p2p] -listenaddr = ":30311" # flag --port -bootnodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] -# flag --bootnodes - -[ethstats] -[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 - - -[bootnodes] -main =[] -test =[] \ No newline at end of file diff --git a/cmd/XDC/testdata/config.toml b/cmd/XDC/testdata/config.toml new file mode 100644 index 0000000000..dcb3d86116 --- /dev/null +++ b/cmd/XDC/testdata/config.toml @@ -0,0 +1,28 @@ +StakeEnable = true # flag --miner ( true : enable staker , false : disable ) +[Eth] +NetworkId = 89 # flag --networkid +SyncMode = "full" # flag --syncmode +GasPrice = 1 # flag --gasprice + +[Shh] + +[Node] +DataDir = "node1/" # flag --datadir +HTTPHost = "localhost" # flag --rpcaddr +HTTPPort = 8501 # flag --rpcport +HTTPModules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi +[Node.P2P] +ListenAddr = ":30311" # flag --port +BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] +# flag --bootnodes + +[Ethstats] +[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 + + +[Bootnodes] +Mainnet =[] +Testnet =[] \ No newline at end of file diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index 2252f600b2..2f3fc7e1fe 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -380,12 +380,12 @@ const ( // Config are the configuration parameters of the ethash. type Config struct { - CacheDir string `toml:"cachedir"` - CachesInMem int `toml:"cachesinmem"` - CachesOnDisk int `toml:"cachesinmem"` - DatasetDir string `toml:"cachesinmem"` - DatasetsInMem int `toml:"cachesinmem"` - DatasetsOnDisk int `toml:"cachesinmem"` + CacheDir string + CachesInMem int + CachesOnDisk int + DatasetDir string + DatasetsInMem int + DatasetsOnDisk int PowMode Mode } diff --git a/dashboard/config.go b/dashboard/config.go index de4dbf4fd5..16e27ee825 100644 --- a/dashboard/config.go +++ b/dashboard/config.go @@ -29,13 +29,13 @@ var DefaultConfig = Config{ type Config struct { // Host is the host interface on which to start the dashboard server. If this // field is empty, no dashboard will be started. - Host string `toml:"host,default=localhost"` + Host string `toml:",omitempty"` // Port is the TCP port number on which to start the dashboard server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - Port int `toml:"port,default=8080"` + Port int `toml:",omitempty"` // Refresh is the refresh rate of the data updates, the chartEntry will be collected this often. - Refresh time.Duration + Refresh time.Duration `toml:",omitempty"` } \ No newline at end of file diff --git a/eth/config.go b/eth/config.go index 28979d1534..52b5c71ad7 100644 --- a/eth/config.go +++ b/eth/config.go @@ -79,11 +79,9 @@ type Config struct { Genesis *core.Genesis `toml:",omitempty"` // Protocol options - NetworkId uint64 `toml:"NetworkId,default=1"` // Network ID to use for selecting peers to connect to ,default=1 - SyncMode downloader.SyncMode `toml:"SyncMode,default=FastSync"` - NoPruning bool - - // Light client options + NetworkId uint64 // Network ID to use for selecting peers to connect to + SyncMode downloader.SyncMode NoPruning bool + // Light client options LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests LightPeers int `toml:",omitempty"` // Maximum number of LES client peers @@ -98,7 +96,7 @@ type Config struct { Etherbase common.Address `toml:",omitempty"` MinerThreads int `toml:",omitempty"` ExtraData []byte `toml:",omitempty"` - GasPrice *big.Int `toml:"GasPrice"` + GasPrice *big.Int // Ethash options Ethash ethash.Config diff --git a/node/config.go b/node/config.go index f066f9bd0d..d1b2432e18 100644 --- a/node/config.go +++ b/node/config.go @@ -53,7 +53,7 @@ type Config struct { Name string `toml:"-"` // UserIdent, if set, is used as an additional component in the devp2p node identifier. - UserIdent string `toml:"identity"` + UserIdent string `toml:",omitempty"` // Version should be set to the version number of the program. It is used // in the devp2p node identifier. @@ -64,10 +64,10 @@ type Config struct { // registered services, instead those can use utility methods to create/access // databases or flat files. This enables ephemeral nodes which can fully reside // in memory. - DataDir string `toml:"datadir"` - + DataDir string + // Configuration of peer-to-peer networking. - P2P p2p.Config `toml:"p2p"` + P2P p2p.Config // KeyStoreDir is the file system folder that contains private keys. The directory can // be specified as a relative path, in which case it is resolved relative to the @@ -76,11 +76,11 @@ type Config struct { // If KeyStoreDir is empty, the default location is the "keystore" subdirectory of // DataDir. If DataDir is unspecified and KeyStoreDir is empty, an ephemeral directory // is created by New and destroyed when the node is stopped. - KeyStoreDir string `toml:"keystore"` + KeyStoreDir string `toml:",omitempty"` // UseLightweightKDF lowers the memory and CPU requirements of the key store // scrypt KDF at the expense of security. - UseLightweightKDF bool `toml:"lightkdf"` + UseLightweightKDF bool `toml:",omitempty"` // NoUSB disables hardware wallet monitoring and connectivity. NoUSB bool `toml:",omitempty"` @@ -93,12 +93,12 @@ type Config struct { // HTTPHost is the host interface on which to start the HTTP RPC server. If this // field is empty, no HTTP API endpoint will be started. - HTTPHost string `toml:"http_host"` + HTTPHost string `toml:",omitempty"` // HTTPPort is the TCP port number on which to start the HTTP RPC server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - HTTPPort int `toml:"http_port"` + HTTPPort int `toml:",omitempty"` // HTTPCors is the Cross-Origin Resource Sharing header to send to requesting // clients. Please be aware that CORS is a browser enforced security, it's fully @@ -117,7 +117,7 @@ type Config struct { // HTTPModules is a list of API modules to expose via the HTTP RPC interface. // If the module list is empty, all RPC API endpoints designated public will be // exposed. - HTTPModules []string `toml:"http_modules"` + HTTPModules []string `toml:",omitempty"` // WSHost is the host interface on which to start the websocket RPC server. If // this field is empty, no websocket API endpoint will be started. diff --git a/p2p/server.go b/p2p/server.go index 472ddee52b..db80a5a659 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -86,12 +86,12 @@ type Config struct { // BootstrapNodes are used to establish connectivity // with the rest of the network. - BootstrapNodes []*discover.Node `toml:"bootnodes"` + BootstrapNodes []*discover.Node // BootstrapNodesV5 are used to establish connectivity // with the rest of the network using the V5 discovery // protocol. - BootstrapNodesV5 []*discv5.Node `toml:"bootnodes_v5"` + BootstrapNodesV5 []*discv5.Node `toml:",omitempty"` // Static nodes are used as pre-configured connections which are always // maintained and re-connected on disconnects. @@ -121,7 +121,7 @@ type Config struct { // If the port is zero, the operating system will pick a port. The // ListenAddr field will be updated with the actual address when // the server is started. - ListenAddr string `toml:"listenaddr,default=30303"` + ListenAddr string // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the