github.com/daeglee/go-ethereum@v0.0.0-20190504220456-cad3e8d18e9b/eth/config.go (about) 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 17 package eth 18 19 import ( 20 "math/big" 21 "os" 22 "os/user" 23 "path/filepath" 24 "runtime" 25 "time" 26 27 "github.com/ethereum/go-ethereum/common" 28 "github.com/ethereum/go-ethereum/common/hexutil" 29 "github.com/ethereum/go-ethereum/consensus/ethash" 30 "github.com/ethereum/go-ethereum/core" 31 "github.com/ethereum/go-ethereum/eth/downloader" 32 "github.com/ethereum/go-ethereum/eth/gasprice" 33 "github.com/ethereum/go-ethereum/params" 34 ) 35 36 // DefaultConfig contains default settings for use on the Ethereum main net. 37 var DefaultConfig = Config{ 38 SyncMode: downloader.FastSync, 39 Ethash: ethash.Config{ 40 CacheDir: "ethash", 41 CachesInMem: 2, 42 CachesOnDisk: 3, 43 DatasetsInMem: 1, 44 DatasetsOnDisk: 2, 45 }, 46 NetworkId: 1, 47 LightPeers: 100, 48 DatabaseCache: 512, 49 TrieCleanCache: 256, 50 TrieDirtyCache: 256, 51 TrieTimeout: 60 * time.Minute, 52 MinerGasFloor: 8000000, 53 MinerGasCeil: 8000000, 54 MinerGasPrice: big.NewInt(params.GWei), 55 MinerRecommit: 3 * time.Second, 56 57 TxPool: core.DefaultTxPoolConfig, 58 GPO: gasprice.Config{ 59 Blocks: 20, 60 Percentile: 60, 61 }, 62 } 63 64 func init() { 65 home := os.Getenv("HOME") 66 if home == "" { 67 if user, err := user.Current(); err == nil { 68 home = user.HomeDir 69 } 70 } 71 if runtime.GOOS == "darwin" { 72 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash") 73 } else if runtime.GOOS == "windows" { 74 localappdata := os.Getenv("LOCALAPPDATA") 75 if localappdata != "" { 76 DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash") 77 } else { 78 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash") 79 } 80 } else { 81 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 82 } 83 } 84 85 //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go 86 87 type Config struct { 88 // The genesis block, which is inserted if the database is empty. 89 // If nil, the Ethereum main net block is used. 90 Genesis *core.Genesis `toml:",omitempty"` 91 92 // Protocol options 93 NetworkId uint64 // Network ID to use for selecting peers to connect to 94 SyncMode downloader.SyncMode 95 NoPruning bool 96 97 // Whitelist of required block number -> hash values to accept 98 Whitelist map[uint64]common.Hash `toml:"-"` 99 100 // Light client options 101 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 102 LightBandwidthIn int `toml:",omitempty"` // Incoming bandwidth limit for light servers 103 LightBandwidthOut int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 104 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 105 OnlyAnnounce bool // Maximum number of LES client peers 106 107 // Ultra Light client options 108 ULC *ULCConfig `toml:",omitempty"` 109 110 // Database options 111 SkipBcVersionCheck bool `toml:"-"` 112 DatabaseHandles int `toml:"-"` 113 DatabaseCache int 114 115 TrieCleanCache int 116 TrieDirtyCache int 117 TrieTimeout time.Duration 118 119 // Mining-related options 120 Etherbase common.Address `toml:",omitempty"` 121 MinerNotify []string `toml:",omitempty"` 122 MinerExtraData []byte `toml:",omitempty"` 123 MinerGasFloor uint64 124 MinerGasCeil uint64 125 MinerGasPrice *big.Int 126 MinerRecommit time.Duration 127 MinerNoverify bool 128 129 // Ethash options 130 Ethash ethash.Config 131 132 // Transaction pool options 133 TxPool core.TxPoolConfig 134 135 // Gas Price Oracle options 136 GPO gasprice.Config 137 138 // Enables tracking of SHA3 preimages in the VM 139 EnablePreimageRecording bool 140 141 // Miscellaneous options 142 DocRoot string `toml:"-"` 143 144 // Type of the EWASM interpreter ("" for default) 145 EWASMInterpreter string 146 147 // Type of the EVM interpreter ("" for default) 148 EVMInterpreter string 149 150 // Constantinople block override (TODO: remove after the fork) 151 ConstantinopleOverride *big.Int 152 } 153 154 type configMarshaling struct { 155 MinerExtraData hexutil.Bytes 156 }