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