github.com/hyperion-hyn/go-ethereum@v2.4.0+incompatible/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/consensus/istanbul" 31 "github.com/ethereum/go-ethereum/core" 32 "github.com/ethereum/go-ethereum/eth/downloader" 33 "github.com/ethereum/go-ethereum/eth/gasprice" 34 "github.com/ethereum/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: 1337, 48 LightPeers: 100, 49 DatabaseCache: 768, 50 TrieCache: 256, 51 TrieTimeout: 60 * time.Minute, 52 MinerGasFloor: params.MinGasLimit, 53 MinerGasCeil: params.GenesisGasLimit, 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 Istanbul: *istanbul.DefaultConfig, 64 } 65 66 func init() { 67 home := os.Getenv("HOME") 68 if home == "" { 69 if user, err := user.Current(); err == nil { 70 home = user.HomeDir 71 } 72 } 73 if runtime.GOOS == "windows" { 74 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash") 75 } else { 76 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 77 } 78 } 79 80 //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go 81 82 type Config struct { 83 // The genesis block, which is inserted if the database is empty. 84 // If nil, the Ethereum main net block is used. 85 Genesis *core.Genesis `toml:",omitempty"` 86 87 // Protocol options 88 NetworkId uint64 // Network ID to use for selecting peers to connect to 89 SyncMode downloader.SyncMode 90 NoPruning bool 91 92 // Light client options 93 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 94 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 95 96 // Database options 97 SkipBcVersionCheck bool `toml:"-"` 98 DatabaseHandles int `toml:"-"` 99 DatabaseCache int 100 TrieCache int 101 TrieTimeout time.Duration 102 103 // Mining-related options 104 Etherbase common.Address `toml:",omitempty"` 105 MinerNotify []string `toml:",omitempty"` 106 MinerExtraData []byte `toml:",omitempty"` 107 MinerGasFloor uint64 108 MinerGasCeil uint64 109 MinerGasPrice *big.Int 110 MinerRecommit time.Duration 111 MinerNoverify bool 112 113 // Ethash options 114 Ethash ethash.Config 115 116 // Transaction pool options 117 TxPool core.TxPoolConfig 118 119 // Gas Price Oracle options 120 GPO gasprice.Config 121 122 // Enables tracking of SHA3 preimages in the VM 123 EnablePreimageRecording bool 124 125 RaftMode bool 126 EnableNodePermission bool 127 // Istanbul options 128 Istanbul istanbul.Config 129 130 // Miscellaneous options 131 DocRoot string `toml:"-"` 132 133 // Type of the EWASM interpreter ("" for default) 134 EWASMInterpreter string 135 // Type of the EVM interpreter ("" for default) 136 EVMInterpreter string 137 } 138 139 type Mode uint 140 141 const ( 142 ModeNormal Mode = iota 143 ModeShared 144 ModeTest 145 ModeFake 146 ModeFullFake 147 ) 148 149 type configMarshaling struct { 150 MinerExtraData hexutil.Bytes 151 }