github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/eth/config.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 19:16:37</date> 10 //</624450087807881216> 11 12 13 package eth 14 15 import ( 16 "math/big" 17 "os" 18 "os/user" 19 "path/filepath" 20 "runtime" 21 "time" 22 23 "github.com/ethereum/go-ethereum/common" 24 "github.com/ethereum/go-ethereum/common/hexutil" 25 "github.com/ethereum/go-ethereum/consensus/ethash" 26 "github.com/ethereum/go-ethereum/core" 27 "github.com/ethereum/go-ethereum/eth/downloader" 28 "github.com/ethereum/go-ethereum/eth/gasprice" 29 "github.com/ethereum/go-ethereum/params" 30 ) 31 32 //defaultconfig包含在以太坊主网上使用的默认设置。 33 var DefaultConfig = Config{ 34 SyncMode: downloader.FastSync, 35 Ethash: ethash.Config{ 36 CacheDir: "ethash", 37 CachesInMem: 2, 38 CachesOnDisk: 3, 39 DatasetsInMem: 1, 40 DatasetsOnDisk: 2, 41 }, 42 NetworkId: 1, 43 LightPeers: 100, 44 DatabaseCache: 512, 45 TrieCleanCache: 256, 46 TrieDirtyCache: 256, 47 TrieTimeout: 60 * time.Minute, 48 MinerGasFloor: 8000000, 49 MinerGasCeil: 8000000, 50 MinerGasPrice: big.NewInt(params.GWei), 51 MinerRecommit: 3 * time.Second, 52 53 TxPool: core.DefaultTxPoolConfig, 54 GPO: gasprice.Config{ 55 Blocks: 20, 56 Percentile: 60, 57 }, 58 } 59 60 func init() { 61 home := os.Getenv("HOME") 62 if home == "" { 63 if user, err := user.Current(); err == nil { 64 home = user.HomeDir 65 } 66 } 67 if runtime.GOOS == "windows" { 68 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash") 69 } else { 70 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 71 } 72 } 73 74 //go:生成gencodec-type config-field override configmarshaling-formats toml-out gen_config.go 75 76 type Config struct { 77 //如果数据库为空,则插入Genesis块。 78 //如果为零,则使用以太坊主网块。 79 Genesis *core.Genesis `toml:",omitempty"` 80 81 //协议选项 82 NetworkId uint64 //Network ID to use for selecting peers to connect to 83 SyncMode downloader.SyncMode 84 NoPruning bool 85 86 //所需块号的白名单->要接受的哈希值 87 Whitelist map[uint64]common.Hash `toml:"-"` 88 89 //轻客户端选项 90 LightServ int `toml:",omitempty"` //允许LES请求的最大时间百分比 91 LightPeers int `toml:",omitempty"` //最大LES客户端对等数 92 93 //数据库选项 94 SkipBcVersionCheck bool `toml:"-"` 95 DatabaseHandles int `toml:"-"` 96 DatabaseCache int 97 TrieCleanCache int 98 TrieDirtyCache int 99 TrieTimeout time.Duration 100 101 //Mining-related options 102 Etherbase common.Address `toml:",omitempty"` 103 MinerNotify []string `toml:",omitempty"` 104 MinerExtraData []byte `toml:",omitempty"` 105 MinerGasFloor uint64 106 MinerGasCeil uint64 107 MinerGasPrice *big.Int 108 MinerRecommit time.Duration 109 MinerNoverify bool 110 111 //乙烯利选项 112 Ethash ethash.Config 113 114 //事务池选项 115 TxPool core.TxPoolConfig 116 117 //天然气价格Oracle选项 118 GPO gasprice.Config 119 120 //允许跟踪虚拟机中的sha3 preimages 121 EnablePreimageRecording bool 122 123 //其他选项 124 DocRoot string `toml:"-"` 125 126 //ewasm解释器的类型(默认为(“”)) 127 EWASMInterpreter string 128 129 //Type of the EVM interpreter ("" for default) 130 EVMInterpreter string 131 132 //君士坦丁堡区块覆盖(TODO:在分叉后移除) 133 ConstantinopleOverride *big.Int 134 } 135 136 type configMarshaling struct { 137 MinerExtraData hexutil.Bytes 138 } 139