github.com/myafeier/go-ethereum@v1.6.8-0.20170719123245-3e0dbe0eaa72/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 26 "github.com/ethereum/go-ethereum/common" 27 "github.com/ethereum/go-ethereum/common/hexutil" 28 "github.com/ethereum/go-ethereum/core" 29 "github.com/ethereum/go-ethereum/eth/downloader" 30 "github.com/ethereum/go-ethereum/eth/gasprice" 31 "github.com/ethereum/go-ethereum/params" 32 ) 33 34 // DefaultConfig contains default settings for use on the Ethereum main net. 35 var DefaultConfig = Config{ 36 SyncMode: downloader.FastSync, 37 EthashCacheDir: "ethash", 38 EthashCachesInMem: 2, 39 EthashCachesOnDisk: 3, 40 EthashDatasetsInMem: 1, 41 EthashDatasetsOnDisk: 2, 42 NetworkId: 1, 43 LightPeers: 20, 44 DatabaseCache: 128, 45 GasPrice: big.NewInt(18 * params.Shannon), 46 47 TxPool: core.DefaultTxPoolConfig, 48 GPO: gasprice.Config{ 49 Blocks: 10, 50 Percentile: 50, 51 }, 52 } 53 54 func init() { 55 home := os.Getenv("HOME") 56 if home == "" { 57 if user, err := user.Current(); err == nil { 58 home = user.HomeDir 59 } 60 } 61 if runtime.GOOS == "windows" { 62 DefaultConfig.EthashDatasetDir = filepath.Join(home, "AppData", "Ethash") 63 } else { 64 DefaultConfig.EthashDatasetDir = filepath.Join(home, ".ethash") 65 } 66 } 67 68 //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go 69 70 type Config struct { 71 // The genesis block, which is inserted if the database is empty. 72 // If nil, the Ethereum main net block is used. 73 Genesis *core.Genesis `toml:",omitempty"` 74 75 // Protocol options 76 NetworkId uint64 // Network ID to use for selecting peers to connect to 77 SyncMode downloader.SyncMode 78 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 MaxPeers int `toml:"-"` // Maximum number of global peers 83 84 // Database options 85 SkipBcVersionCheck bool `toml:"-"` 86 DatabaseHandles int `toml:"-"` 87 DatabaseCache int 88 89 // Mining-related options 90 Etherbase common.Address `toml:",omitempty"` 91 MinerThreads int `toml:",omitempty"` 92 ExtraData []byte `toml:",omitempty"` 93 GasPrice *big.Int 94 95 // Ethash options 96 EthashCacheDir string 97 EthashCachesInMem int 98 EthashCachesOnDisk int 99 EthashDatasetDir string 100 EthashDatasetsInMem int 101 EthashDatasetsOnDisk int 102 103 // Transaction pool options 104 TxPool core.TxPoolConfig 105 106 // Gas Price Oracle options 107 GPO gasprice.Config 108 109 // Enables tracking of SHA3 preimages in the VM 110 EnablePreimageRecording bool 111 112 // Miscellaneous options 113 DocRoot string `toml:"-"` 114 PowFake bool `toml:"-"` 115 PowTest bool `toml:"-"` 116 PowShared bool `toml:"-"` 117 } 118 119 type configMarshaling struct { 120 ExtraData hexutil.Bytes 121 }