config.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright 2017 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package eth
  17. import (
  18. "math/big"
  19. "os"
  20. "os/user"
  21. "path/filepath"
  22. "runtime"
  23. "github.com/ethereum/go-ethereum/common"
  24. "github.com/ethereum/go-ethereum/common/hexutil"
  25. "github.com/ethereum/go-ethereum/core"
  26. "github.com/ethereum/go-ethereum/eth/downloader"
  27. "github.com/ethereum/go-ethereum/eth/gasprice"
  28. "github.com/ethereum/go-ethereum/params"
  29. )
  30. // DefaultConfig contains default settings for use on the Ethereum main net.
  31. var DefaultConfig = Config{
  32. SyncMode: downloader.FastSync,
  33. EthashCacheDir: "ethash",
  34. EthashCachesInMem: 2,
  35. EthashCachesOnDisk: 3,
  36. EthashDatasetsInMem: 1,
  37. EthashDatasetsOnDisk: 2,
  38. NetworkId: 1,
  39. LightPeers: 20,
  40. DatabaseCache: 128,
  41. GasPrice: big.NewInt(18 * params.Shannon),
  42. TxPool: core.DefaultTxPoolConfig,
  43. GPO: gasprice.Config{
  44. Blocks: 10,
  45. Percentile: 50,
  46. },
  47. }
  48. func init() {
  49. home := os.Getenv("HOME")
  50. if home == "" {
  51. if user, err := user.Current(); err == nil {
  52. home = user.HomeDir
  53. }
  54. }
  55. if runtime.GOOS == "windows" {
  56. DefaultConfig.EthashDatasetDir = filepath.Join(home, "AppData", "Ethash")
  57. } else {
  58. DefaultConfig.EthashDatasetDir = filepath.Join(home, ".ethash")
  59. }
  60. }
  61. //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
  62. type Config struct {
  63. // The genesis block, which is inserted if the database is empty.
  64. // If nil, the Ethereum main net block is used.
  65. Genesis *core.Genesis `toml:",omitempty"`
  66. // Protocol options
  67. NetworkId uint64 // Network ID to use for selecting peers to connect to
  68. SyncMode downloader.SyncMode
  69. // Light client options
  70. LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
  71. LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
  72. // Database options
  73. SkipBcVersionCheck bool `toml:"-"`
  74. DatabaseHandles int `toml:"-"`
  75. DatabaseCache int
  76. // Mining-related options
  77. Etherbase common.Address `toml:",omitempty"`
  78. MinerThreads int `toml:",omitempty"`
  79. ExtraData []byte `toml:",omitempty"`
  80. GasPrice *big.Int
  81. // Ethash options
  82. EthashCacheDir string
  83. EthashCachesInMem int
  84. EthashCachesOnDisk int
  85. EthashDatasetDir string
  86. EthashDatasetsInMem int
  87. EthashDatasetsOnDisk int
  88. // Transaction pool options
  89. TxPool core.TxPoolConfig
  90. // Gas Price Oracle options
  91. GPO gasprice.Config
  92. // Enables tracking of SHA3 preimages in the VM
  93. EnablePreimageRecording bool
  94. // Miscellaneous options
  95. DocRoot string `toml:"-"`
  96. PowFake bool `toml:"-"`
  97. PowTest bool `toml:"-"`
  98. PowShared bool `toml:"-"`
  99. }
  100. type configMarshaling struct {
  101. ExtraData hexutil.Bytes
  102. }