github.com/tuotoo/go-ethereum@v1.7.4-0.20171121184211-049797d40a24/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 83 // Database options 84 SkipBcVersionCheck bool `toml:"-"` 85 DatabaseHandles int `toml:"-"` 86 DatabaseCache int 87 88 // Mining-related options 89 Etherbase common.Address `toml:",omitempty"` 90 MinerThreads int `toml:",omitempty"` 91 ExtraData []byte `toml:",omitempty"` 92 GasPrice *big.Int 93 94 // Ethash options 95 EthashCacheDir string 96 EthashCachesInMem int 97 EthashCachesOnDisk int 98 EthashDatasetDir string 99 EthashDatasetsInMem int 100 EthashDatasetsOnDisk int 101 102 // Transaction pool options 103 TxPool core.TxPoolConfig 104 105 // Gas Price Oracle options 106 GPO gasprice.Config 107 108 // Enables tracking of SHA3 preimages in the VM 109 EnablePreimageRecording bool 110 111 // Miscellaneous options 112 DocRoot string `toml:"-"` 113 PowFake bool `toml:"-"` 114 PowTest bool `toml:"-"` 115 PowShared bool `toml:"-"` 116 } 117 118 type configMarshaling struct { 119 ExtraData hexutil.Bytes 120 }