config.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. "time"
  24. "github.com/ethereum/go-ethereum/common"
  25. "github.com/ethereum/go-ethereum/common/hexutil"
  26. "github.com/ethereum/go-ethereum/consensus/ethash"
  27. "github.com/ethereum/go-ethereum/core"
  28. "github.com/ethereum/go-ethereum/eth/downloader"
  29. "github.com/ethereum/go-ethereum/eth/gasprice"
  30. "github.com/ethereum/go-ethereum/params"
  31. )
  32. // DefaultConfig contains default settings for use on the Ethereum main net.
  33. var DefaultConfig = Config{
  34. SyncMode: downloader.FastSync,
  35. Ethash: ethash.Config{
  36. CacheDir: "ethash",
  37. CachesInMem: 2,
  38. CachesOnDisk: 3,
  39. DatasetsInMem: 1,
  40. DatasetsOnDisk: 2,
  41. },
  42. NetworkId: 1,
  43. LightPeers: 100,
  44. DatabaseCache: 768,
  45. TrieCache: 256,
  46. TrieTimeout: 60 * time.Minute,
  47. MinerGasFloor: 8000000,
  48. MinerGasCeil: 8000000,
  49. MinerGasPrice: big.NewInt(params.GWei),
  50. MinerRecommit: 3 * time.Second,
  51. TxPool: core.DefaultTxPoolConfig,
  52. GPO: gasprice.Config{
  53. Blocks: 20,
  54. Percentile: 60,
  55. },
  56. }
  57. func init() {
  58. home := os.Getenv("HOME")
  59. if home == "" {
  60. if user, err := user.Current(); err == nil {
  61. home = user.HomeDir
  62. }
  63. }
  64. if runtime.GOOS == "windows" {
  65. DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash")
  66. } else {
  67. DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash")
  68. }
  69. }
  70. //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
  71. type Config struct {
  72. // The genesis block, which is inserted if the database is empty.
  73. // If nil, the Ethereum main net block is used.
  74. Genesis *core.Genesis `toml:",omitempty"`
  75. // Protocol options
  76. NetworkId uint64 // Network ID to use for selecting peers to connect to
  77. SyncMode downloader.SyncMode
  78. NoPruning bool
  79. // Light client options
  80. LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
  81. LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
  82. // Database options
  83. SkipBcVersionCheck bool `toml:"-"`
  84. DatabaseHandles int `toml:"-"`
  85. DatabaseCache int
  86. TrieCache int
  87. TrieTimeout time.Duration
  88. // Mining-related options
  89. Etherbase common.Address `toml:",omitempty"`
  90. MinerNotify []string `toml:",omitempty"`
  91. MinerExtraData []byte `toml:",omitempty"`
  92. MinerGasFloor uint64
  93. MinerGasCeil uint64
  94. MinerGasPrice *big.Int
  95. MinerRecommit time.Duration
  96. MinerNoverify bool
  97. // Ethash options
  98. Ethash ethash.Config
  99. // Transaction pool options
  100. TxPool core.TxPoolConfig
  101. // Gas Price Oracle options
  102. GPO gasprice.Config
  103. // Enables tracking of SHA3 preimages in the VM
  104. EnablePreimageRecording bool
  105. // Miscellaneous options
  106. DocRoot string `toml:"-"`
  107. }
  108. type configMarshaling struct {
  109. MinerExtraData hexutil.Bytes
  110. }