github.com/valorbit/go-ethereum@v1.9.11-rc4/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 "strings" 26 "time" 27 28 "github.com/valorbit/go-ethereum/common" 29 "github.com/valorbit/go-ethereum/consensus/ethash" 30 "github.com/valorbit/go-ethereum/core" 31 "github.com/valorbit/go-ethereum/eth/downloader" 32 "github.com/valorbit/go-ethereum/eth/gasprice" 33 "github.com/valorbit/go-ethereum/miner" 34 "github.com/valorbit/go-ethereum/params" 35 ) 36 37 // DefaultConfig contains default settings for use on the Ethereum main net. 38 var DefaultConfig = Config{ 39 SyncMode: downloader.FastSync, 40 Ethash: ethash.Config{ 41 CacheDir: "ethash", 42 CachesInMem: 2, 43 CachesOnDisk: 3, 44 DatasetsInMem: 1, 45 DatasetsOnDisk: 2, 46 }, 47 NetworkId: 38, 48 LightPeers: 100, 49 UltraLightFraction: 75, 50 DatabaseCache: 512, 51 TrieCleanCache: 256, 52 TrieDirtyCache: 256, 53 TrieTimeout: 60 * time.Minute, 54 Miner: miner.Config{ 55 GasFloor: 10000000, 56 GasCeil: 10000000, 57 GasPrice: big.NewInt(params.GWei), 58 Recommit: 3 * time.Second, 59 }, 60 TxPool: core.DefaultTxPoolConfig, 61 GPO: gasprice.Config{ 62 Blocks: 20, 63 Percentile: 60, 64 }, 65 } 66 67 func init() { 68 69 defaultSubDir := "Valorhash" 70 71 home := os.Getenv("HOME") 72 if home == "" { 73 if user, err := user.Current(); err == nil { 74 home = user.HomeDir 75 } 76 } 77 if runtime.GOOS == "darwin" { 78 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", defaultSubDir) 79 } else if runtime.GOOS == "windows" { 80 localappdata := os.Getenv("LOCALAPPDATA") 81 if localappdata != "" { 82 DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, defaultSubDir) 83 } else { 84 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", defaultSubDir) 85 } 86 } else { 87 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "."+strings.ToLower(defaultSubDir)) 88 } 89 } 90 91 //go:generate gencodec -type Config -formats toml -out gen_config.go 92 93 type Config struct { 94 // The genesis block, which is inserted if the database is empty. 95 // If nil, the Ethereum main net block is used. 96 Genesis *core.Genesis `toml:",omitempty"` 97 98 // Protocol options 99 NetworkId uint64 // Network ID to use for selecting peers to connect to 100 SyncMode downloader.SyncMode 101 102 // This can be set to list of enrtree:// URLs which will be queried for 103 // for nodes to connect to. 104 DiscoveryURLs []string 105 106 NoPruning bool // Whether to disable pruning and flush everything to disk 107 NoPrefetch bool // Whether to disable prefetching and only load state on demand 108 109 // Whitelist of required block number -> hash values to accept 110 Whitelist map[uint64]common.Hash `toml:"-"` 111 112 // Light client options 113 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 114 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 115 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 116 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 117 118 // Ultra Light client options 119 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 120 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 121 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 122 123 // Database options 124 SkipBcVersionCheck bool `toml:"-"` 125 DatabaseHandles int `toml:"-"` 126 DatabaseCache int 127 DatabaseFreezer string 128 129 TrieCleanCache int 130 TrieDirtyCache int 131 TrieTimeout time.Duration 132 133 // Mining options 134 Miner miner.Config 135 136 // Ethash options 137 Ethash ethash.Config 138 139 // Transaction pool options 140 TxPool core.TxPoolConfig 141 142 // Gas Price Oracle options 143 GPO gasprice.Config 144 145 // Enables tracking of SHA3 preimages in the VM 146 EnablePreimageRecording bool 147 148 // Miscellaneous options 149 DocRoot string `toml:"-"` 150 151 // Type of the EWASM interpreter ("" for default) 152 EWASMInterpreter string 153 154 // Type of the EVM interpreter ("" for default) 155 EVMInterpreter string 156 157 // RPCGasCap is the global gas cap for eth-call variants. 158 RPCGasCap *big.Int `toml:",omitempty"` 159 160 // Checkpoint is a hardcoded checkpoint which can be nil. 161 Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` 162 163 // CheckpointOracle is the configuration for checkpoint oracle. 164 CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` 165 166 // Istanbul block override (TODO: remove after the fork) 167 OverrideIstanbul *big.Int `toml:",omitempty"` 168 169 // MuirGlacier block override (TODO: remove after the fork) 170 OverrideMuirGlacier *big.Int `toml:",omitempty"` 171 }