github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/eth/gen_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 12:09:38</date> 10 //</624342635858890752> 11 12 //代码由github.com/fjl/gencodec生成。不要编辑。 13 14 package eth 15 16 import ( 17 "math/big" 18 "time" 19 20 "github.com/ethereum/go-ethereum/common" 21 "github.com/ethereum/go-ethereum/common/hexutil" 22 "github.com/ethereum/go-ethereum/consensus/ethash" 23 "github.com/ethereum/go-ethereum/core" 24 "github.com/ethereum/go-ethereum/eth/downloader" 25 "github.com/ethereum/go-ethereum/eth/gasprice" 26 ) 27 28 var _ = (*configMarshaling)(nil) 29 30 //MsHaltOML封为TOML。 31 func (c Config) MarshalTOML() (interface{}, error) { 32 type Config struct { 33 Genesis *core.Genesis `toml:",omitempty"` 34 NetworkId uint64 35 SyncMode downloader.SyncMode 36 NoPruning bool 37 LightServ int `toml:",omitempty"` 38 LightPeers int `toml:",omitempty"` 39 SkipBcVersionCheck bool `toml:"-"` 40 DatabaseHandles int `toml:"-"` 41 DatabaseCache int 42 TrieCache int 43 TrieTimeout time.Duration 44 //etherbase common.address`toml:“,omitempty”` 45 Validator common.Address `toml:",omitempty"` 46 Coinbase common.Address `toml:",omitempty"` 47 MinerThreads int `toml:",omitempty"` 48 MinerNotify []string `toml:",omitempty"` 49 MinerExtraData hexutil.Bytes `toml:",omitempty"` 50 MinerGasPrice *big.Int 51 MinerRecommit time.Duration 52 Ethash ethash.Config 53 TxPool core.TxPoolConfig 54 GPO gasprice.Config 55 EnablePreimageRecording bool 56 DocRoot string `toml:"-"` 57 } 58 var enc Config 59 enc.Genesis = c.Genesis 60 enc.NetworkId = c.NetworkId 61 enc.SyncMode = c.SyncMode 62 enc.NoPruning = c.NoPruning 63 enc.LightServ = c.LightServ 64 enc.LightPeers = c.LightPeers 65 enc.SkipBcVersionCheck = c.SkipBcVersionCheck 66 enc.DatabaseHandles = c.DatabaseHandles 67 enc.DatabaseCache = c.DatabaseCache 68 enc.TrieCache = c.TrieCache 69 enc.TrieTimeout = c.TrieTimeout 70 //Enc.EtherBase=C.EtherBase 71 enc.Validator = c.Validator 72 enc.Coinbase = c.Coinbase 73 enc.MinerThreads = c.MinerThreads 74 enc.MinerNotify = c.MinerNotify 75 enc.MinerExtraData = c.MinerExtraData 76 enc.MinerGasPrice = c.MinerGasPrice 77 enc.MinerRecommit = c.MinerRecommit 78 enc.Ethash = c.Ethash 79 enc.TxPool = c.TxPool 80 enc.GPO = c.GPO 81 enc.EnablePreimageRecording = c.EnablePreimageRecording 82 enc.DocRoot = c.DocRoot 83 return &enc, nil 84 } 85 86 //取消标记从Toml取消标记。 87 func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { 88 type Config struct { 89 Genesis *core.Genesis `toml:",omitempty"` 90 NetworkId *uint64 91 SyncMode *downloader.SyncMode 92 NoPruning *bool 93 LightServ *int `toml:",omitempty"` 94 LightPeers *int `toml:",omitempty"` 95 SkipBcVersionCheck *bool `toml:"-"` 96 DatabaseHandles *int `toml:"-"` 97 DatabaseCache *int 98 TrieCache *int 99 TrieTimeout *time.Duration 100 //etherbase*common.address`toml:“,omitempty”` 101 Validator *common.Address `toml:",omitempty"` 102 Coinbase *common.Address `toml:",omitempty"` 103 MinerThreads *int `toml:",omitempty"` 104 MinerNotify []string `toml:",omitempty"` 105 MinerExtraData *hexutil.Bytes `toml:",omitempty"` 106 MinerGasPrice *big.Int 107 MinerRecommit *time.Duration 108 Ethash *ethash.Config 109 TxPool *core.TxPoolConfig 110 GPO *gasprice.Config 111 EnablePreimageRecording *bool 112 DocRoot *string `toml:"-"` 113 } 114 var dec Config 115 if err := unmarshal(&dec); err != nil { 116 return err 117 } 118 if dec.Genesis != nil { 119 c.Genesis = dec.Genesis 120 } 121 if dec.NetworkId != nil { 122 c.NetworkId = *dec.NetworkId 123 } 124 if dec.SyncMode != nil { 125 c.SyncMode = *dec.SyncMode 126 } 127 if dec.NoPruning != nil { 128 c.NoPruning = *dec.NoPruning 129 } 130 if dec.LightServ != nil { 131 c.LightServ = *dec.LightServ 132 } 133 if dec.LightPeers != nil { 134 c.LightPeers = *dec.LightPeers 135 } 136 if dec.SkipBcVersionCheck != nil { 137 c.SkipBcVersionCheck = *dec.SkipBcVersionCheck 138 } 139 if dec.DatabaseHandles != nil { 140 c.DatabaseHandles = *dec.DatabaseHandles 141 } 142 if dec.DatabaseCache != nil { 143 c.DatabaseCache = *dec.DatabaseCache 144 } 145 if dec.TrieCache != nil { 146 c.TrieCache = *dec.TrieCache 147 } 148 if dec.TrieTimeout != nil { 149 c.TrieTimeout = *dec.TrieTimeout 150 } 151 /* 152 如果是12月以太坊!= nIL{ 153 C.EtherBase=*十二月EtherBase 154 */ 155 156 if dec.Validator != nil { 157 c.Validator = *dec.Validator 158 } 159 if dec.Coinbase != nil { 160 c.Coinbase = *dec.Coinbase 161 } 162 if dec.MinerThreads != nil { 163 c.MinerThreads = *dec.MinerThreads 164 } 165 if dec.MinerNotify != nil { 166 c.MinerNotify = dec.MinerNotify 167 } 168 if dec.MinerExtraData != nil { 169 c.MinerExtraData = *dec.MinerExtraData 170 } 171 if dec.MinerGasPrice != nil { 172 c.MinerGasPrice = dec.MinerGasPrice 173 } 174 if dec.MinerRecommit != nil { 175 c.MinerRecommit = *dec.MinerRecommit 176 } 177 if dec.Ethash != nil { 178 c.Ethash = *dec.Ethash 179 } 180 if dec.TxPool != nil { 181 c.TxPool = *dec.TxPool 182 } 183 if dec.GPO != nil { 184 c.GPO = *dec.GPO 185 } 186 if dec.EnablePreimageRecording != nil { 187 c.EnablePreimageRecording = *dec.EnablePreimageRecording 188 } 189 if dec.DocRoot != nil { 190 c.DocRoot = *dec.DocRoot 191 } 192 return nil 193 } 194